diff --git a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClient.java b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClient.java index eff4510cd3..a7d33de5bc 100644 --- a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClient.java +++ b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingAsyncClient.java @@ -26,6 +26,7 @@ package org.jclouds.rimuhosting.miro; import org.jclouds.rest.annotations.*; import org.jclouds.rimuhosting.miro.binder.RimuHostingJsonBinder; import org.jclouds.rimuhosting.miro.binder.RimuHostingRebootJsonBinder; +import org.jclouds.rimuhosting.miro.binder.RimuHostingCreateInstanceBinder; import org.jclouds.rimuhosting.miro.data.NewInstance; import org.jclouds.rimuhosting.miro.domain.*; import org.jclouds.rimuhosting.miro.filters.RimuHostingAuthentication; @@ -76,30 +77,28 @@ public interface RimuHostingAsyncClient { @Consumes(MediaType.APPLICATION_JSON) @ExceptionParser(ParseRimuHostingException.class) @ResponseParser(ParseNewInstanceResponseFromJsonResponse.class) - Future createInstance(@BinderParam(RimuHostingJsonBinder.class) NewInstance newInstance); + @MapBinder(RimuHostingCreateInstanceBinder.class) + Future createInstance(@MapEntityParam("name") String name, @MapEntityParam("imageId") String imageId, @MapEntityParam("planId") String planId); + @POST @Path("/orders/new-vps") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + @ExceptionParser(ParseRimuHostingException.class) + @ResponseParser(ParseNewInstanceResponseFromJsonResponse.class) + @MapBinder(RimuHostingCreateInstanceBinder.class) + Future createInstance(@MapEntityParam("name") String name, @MapEntityParam("imageId") String imageId, @MapEntityParam("planId") String planId, @MapEntityParam("password") String password); @GET @Path("/orders/order-{id}-blah/vps") @Consumes(MediaType.APPLICATION_JSON) @ResponseParser(ParseInstanceInfoFromJsonResponse.class) Future getInstanceInfo(@PathParam("id") Long id); - @GET @Path("/orders/order-{id}-blah") @Consumes(MediaType.APPLICATION_JSON) @ResponseParser(ParseInstanceFromJsonResponse.class) @ExceptionParser(ParseRimuHostingException.class) Future getInstance(@PathParam("id") Long id); - - //TODO fix this. - @PUT @Path("/orders/order-{id}-blah/vps/paramters") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @ResponseParser(ParseResizeResponseFromJsonResponse.class) - @ExceptionParser(ParseRimuHostingException.class) - Future resizeInstance(@PathParam("id") Long id); - @PUT @Path("/orders/order-{id}-blah/vps/running-state") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) diff --git a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingClient.java b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingClient.java index 6f06143b90..948720c023 100644 --- a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingClient.java +++ b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/RimuHostingClient.java @@ -25,6 +25,7 @@ package org.jclouds.rimuhosting.miro; import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.MapEntityParam; import org.jclouds.rimuhosting.miro.binder.RimuHostingJsonBinder; import org.jclouds.rimuhosting.miro.data.NewInstance; import org.jclouds.rimuhosting.miro.domain.*; @@ -33,6 +34,7 @@ import javax.ws.rs.PathParam; import java.util.List; import java.util.SortedSet; import java.util.concurrent.TimeUnit; +import java.util.concurrent.Future; /** * Provides synchronous access to RimuHosting. @@ -51,15 +53,13 @@ public interface RimuHostingClient { SortedSet getPricingPlanList(); - NewInstanceResponse createInstance(@BinderParam(RimuHostingJsonBinder.class)NewInstance newInstance); + NewInstanceResponse createInstance(String name, String imageId, String planId); - InstanceInfo getInstanceInfo(@PathParam("id") Long id); + NewInstanceResponse createInstance(String name, String imageId, String planId, String password); - Instance getInstance(@PathParam("id") Long id); + Instance getInstance(Long id); - InstanceInfo restartInstance(@PathParam("id") Long id); + InstanceInfo restartInstance(Long id); - ResizeResult resizeInstance(@PathParam("id") Long id); - - List destroyInstance(@PathParam("id") Long id); + List destroyInstance(Long id); } diff --git a/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/RimuHostingCreateInstanceBinder.java b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/RimuHostingCreateInstanceBinder.java new file mode 100644 index 0000000000..4fd80855be --- /dev/null +++ b/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/binder/RimuHostingCreateInstanceBinder.java @@ -0,0 +1,24 @@ +package org.jclouds.rimuhosting.miro.binder; + +import org.jclouds.http.HttpRequest; +import org.jclouds.rimuhosting.miro.data.NewInstance; +import org.jclouds.rimuhosting.miro.data.CreateOptions; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; +import java.util.Map; + +/** + * @author Ivan Meredith + */ +public class RimuHostingCreateInstanceBinder extends RimuHostingJsonBinder{ + public void bindToRequest(HttpRequest request, Map postParams) { + String name = checkNotNull(postParams.get("name")); + String imageId = checkNotNull(postParams.get("imageId")); + String planId = checkNotNull(postParams.get("planId")); + //There will be cases when the password is null. + String password = postParams.get("password"); + NewInstance newInstance = new NewInstance(new CreateOptions(name, password, imageId), planId); + bindToRequest(request, newInstance); + } +} diff --git a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java index be69dee874..708b93bbfd 100644 --- a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java +++ b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java @@ -80,8 +80,7 @@ public class RimuHostingClientLiveTest { @Test public void testLifeCycle() { //Get the first image, we dont really care what it is in this test. - NewInstance inst = new NewInstance(new CreateOptions("test.jclouds.org",null,"lenny"),"MIRO1") ; - NewInstanceResponse instanceResponse = connection.createInstance(inst); + NewInstanceResponse instanceResponse = connection.createInstance("test.jclouds.org", "lenny", "MIRO1B"); Instance instance = instanceResponse.getInstance(); //Now we have the instance, lets restart it assertNotNull(instance.getId()); diff --git a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingComputeClient.java b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingComputeClient.java index 488d73de9a..64818b7a13 100644 --- a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingComputeClient.java +++ b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingComputeClient.java @@ -58,7 +58,7 @@ public class RimuHostingComputeClient { public Long start(String name, String planId, String imageId) { logger.debug(">> instantiating RimuHosting VPS name(%s) plan(%s) image(%s)", name, planId, imageId); - NewInstanceResponse instanceRespone = rhClient.createInstance(new NewInstance(new CreateOptions(name,null,imageId), planId)); + NewInstanceResponse instanceRespone = rhClient.createInstance(name, imageId, planId); logger.debug(">> VPS id(%d) started and running.", instanceRespone.getInstance().getId()); return instanceRespone.getInstance().getId(); } diff --git a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingComputeClientLiveTest.java b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingComputeClientLiveTest.java index 0be8cae645..8d0ab665da 100644 --- a/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingComputeClientLiveTest.java +++ b/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingComputeClientLiveTest.java @@ -65,7 +65,7 @@ public class RimuHostingComputeClientLiveTest { IOException { String imageId = "lenny"; String serverName = "test.jclouds.org"; - String planId = "MIRO1"; + String planId = "MIRO1B"; id = client.start(serverName, planId, imageId); Instance instance = rhClient.getInstance(id);