mirror of https://github.com/apache/jclouds.git
Added some javadocs to RimuHostingClient.
Changed createServer to use options. withPassword, withMetaData.
This commit is contained in:
parent
ee38b1e349
commit
fc1b296f33
|
@ -38,7 +38,7 @@ import org.jclouds.rest.annotations.MapPayloadParam;
|
||||||
import org.jclouds.rest.annotations.MatrixParams;
|
import org.jclouds.rest.annotations.MatrixParams;
|
||||||
import org.jclouds.rest.annotations.RequestFilters;
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
import org.jclouds.rest.annotations.ResponseParser;
|
import org.jclouds.rest.annotations.ResponseParser;
|
||||||
import org.jclouds.rimuhosting.miro.binder.RimuHostingCreateInstanceBinder;
|
import org.jclouds.rimuhosting.miro.binder.CreateServerOptions;
|
||||||
import org.jclouds.rimuhosting.miro.binder.RimuHostingRebootJsonBinder;
|
import org.jclouds.rimuhosting.miro.binder.RimuHostingRebootJsonBinder;
|
||||||
import org.jclouds.rimuhosting.miro.domain.Image;
|
import org.jclouds.rimuhosting.miro.domain.Image;
|
||||||
import org.jclouds.rimuhosting.miro.domain.NewServerResponse;
|
import org.jclouds.rimuhosting.miro.domain.NewServerResponse;
|
||||||
|
@ -69,6 +69,9 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
@Endpoint(RimuHosting.class)
|
@Endpoint(RimuHosting.class)
|
||||||
public interface RimuHostingAsyncClient {
|
public interface RimuHostingAsyncClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see RimuHostingClient#getImageList
|
||||||
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("/distributions")
|
@Path("/distributions")
|
||||||
@ResponseParser(ParseImagesFromJsonResponse.class)
|
@ResponseParser(ParseImagesFromJsonResponse.class)
|
||||||
|
@ -77,6 +80,9 @@ public interface RimuHostingAsyncClient {
|
||||||
@ExceptionParser(ParseRimuHostingException.class)
|
@ExceptionParser(ParseRimuHostingException.class)
|
||||||
ListenableFuture<SortedSet<Image>> getImageList();
|
ListenableFuture<SortedSet<Image>> getImageList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see RimuHostingClient#getServerList
|
||||||
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("/orders")
|
@Path("/orders")
|
||||||
@ResponseParser(ParseInstancesFromJsonResponse.class)
|
@ResponseParser(ParseInstancesFromJsonResponse.class)
|
||||||
|
@ -86,6 +92,9 @@ public interface RimuHostingAsyncClient {
|
||||||
@ExceptionParser(ParseRimuHostingException.class)
|
@ExceptionParser(ParseRimuHostingException.class)
|
||||||
ListenableFuture<SortedSet<Server>> getServerList();
|
ListenableFuture<SortedSet<Server>> getServerList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see RimuHostingClient#getPricingPlanList
|
||||||
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("/pricing-plans")
|
@Path("/pricing-plans")
|
||||||
@MatrixParams(keys = "server-type", values = "VPS")
|
@MatrixParams(keys = "server-type", values = "VPS")
|
||||||
|
@ -94,33 +103,22 @@ public interface RimuHostingAsyncClient {
|
||||||
@ResponseParser(ParsePricingPlansFromJsonResponse.class)
|
@ResponseParser(ParsePricingPlansFromJsonResponse.class)
|
||||||
ListenableFuture<SortedSet<PricingPlan>> getPricingPlanList();
|
ListenableFuture<SortedSet<PricingPlan>> getPricingPlanList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see RimuHostingClient#createServer
|
||||||
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("/orders/new-vps")
|
@Path("/orders/new-vps")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@ExceptionParser(ParseRimuHostingException.class)
|
@ExceptionParser(ParseRimuHostingException.class)
|
||||||
@ResponseParser(ParseNewInstanceResponseFromJsonResponse.class)
|
@ResponseParser(ParseNewInstanceResponseFromJsonResponse.class)
|
||||||
@MapBinder(RimuHostingCreateInstanceBinder.class)
|
@MapBinder(CreateServerOptions.class)
|
||||||
ListenableFuture<NewServerResponse> createServer(@MapPayloadParam("name") String name,
|
ListenableFuture<NewServerResponse> createServer(@MapPayloadParam("name") String name,
|
||||||
@MapPayloadParam("imageId") String imageId, @MapPayloadParam("planId") String planId);
|
@MapPayloadParam("imageId") String imageId, @MapPayloadParam("planId") String planId, CreateServerOptions ... options);
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path("/orders/new-vps")
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
@ExceptionParser(ParseRimuHostingException.class)
|
|
||||||
@ResponseParser(ParseNewInstanceResponseFromJsonResponse.class)
|
|
||||||
@MapBinder(RimuHostingCreateInstanceBinder.class)
|
|
||||||
ListenableFuture<NewServerResponse> createServer(@MapPayloadParam("name") String name,
|
|
||||||
@MapPayloadParam("imageId") String imageId, @MapPayloadParam("planId") String planId,
|
|
||||||
@MapPayloadParam("password") String password);
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Path("/orders/order-{id}-blah/vps")
|
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
@ResponseParser(ParseInstanceInfoFromJsonResponse.class)
|
|
||||||
ListenableFuture<ServerInfo> getServerInfo(@PathParam("id") Long id);
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see RimuHostingClient#getServer
|
||||||
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("/orders/order-{id}-blah")
|
@Path("/orders/order-{id}-blah")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
@ -128,6 +126,9 @@ public interface RimuHostingAsyncClient {
|
||||||
@ExceptionParser(ParseRimuHostingException.class)
|
@ExceptionParser(ParseRimuHostingException.class)
|
||||||
ListenableFuture<Server> getServer(@PathParam("id") Long id);
|
ListenableFuture<Server> getServer(@PathParam("id") Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see RimuHostingClient#restartServer
|
||||||
|
*/
|
||||||
@PUT
|
@PUT
|
||||||
@Path("/orders/order-{id}-blah/vps/running-state")
|
@Path("/orders/order-{id}-blah/vps/running-state")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
@ -137,6 +138,9 @@ public interface RimuHostingAsyncClient {
|
||||||
@ExceptionParser(ParseRimuHostingException.class)
|
@ExceptionParser(ParseRimuHostingException.class)
|
||||||
ListenableFuture<ServerInfo> restartServer(@PathParam("id") Long id);
|
ListenableFuture<ServerInfo> restartServer(@PathParam("id") Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see RimuHostingClient#destoryServer
|
||||||
|
*/
|
||||||
@DELETE
|
@DELETE
|
||||||
@Path("/orders/order-{id}-blah/vps")
|
@Path("/orders/order-{id}-blah/vps")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
package org.jclouds.rimuhosting.miro;
|
package org.jclouds.rimuhosting.miro;
|
||||||
|
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
import org.jclouds.rimuhosting.miro.binder.CreateServerOptions;
|
||||||
import org.jclouds.rimuhosting.miro.domain.*;
|
import org.jclouds.rimuhosting.miro.domain.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -36,19 +37,59 @@ import java.util.concurrent.TimeUnit;
|
||||||
@Timeout(duration = 40, timeUnit = TimeUnit.MINUTES)
|
@Timeout(duration = 40, timeUnit = TimeUnit.MINUTES)
|
||||||
public interface RimuHostingClient {
|
public interface RimuHostingClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This operation returns a list of images that can be used for server creation.
|
||||||
|
*c
|
||||||
|
* @see Image
|
||||||
|
*/
|
||||||
SortedSet<Image> getImageList();
|
SortedSet<Image> getImageList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of servers that belong to this account.
|
||||||
|
*
|
||||||
|
* @return An empty set if there are no servers.
|
||||||
|
* @see Server
|
||||||
|
*/
|
||||||
SortedSet<Server> getServerList();
|
SortedSet<Server> getServerList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of pricing plans that can be used for server creation.
|
||||||
|
* @see PricingPlan
|
||||||
|
*/
|
||||||
SortedSet<PricingPlan> getPricingPlanList();
|
SortedSet<PricingPlan> getPricingPlanList();
|
||||||
|
|
||||||
NewServerResponse createServer(String name, String imageId, String planId);
|
/**
|
||||||
|
* This operation creates a node based on its name, imageId and planId.
|
||||||
NewServerResponse createServer(String name, String imageId, String planId, String password);
|
*
|
||||||
|
* A password can be specified with the option {@link CreateServerOptions#withPassword(String) | withPassword()}
|
||||||
|
*
|
||||||
|
* Key-Value @{link {@link MetaData | metadata} can be included with the option {@link CreateServerOptions#withMetaData(List) | withMetaData()}
|
||||||
|
*
|
||||||
|
* @see CreateServerOptions
|
||||||
|
*
|
||||||
|
* TODO: add more CreateServerOptions
|
||||||
|
*/
|
||||||
|
NewServerResponse createServer(String name, String imageId, String planId, CreateServerOptions ... options);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a server based on its id.
|
||||||
|
*
|
||||||
|
* @return null if server id is invalid.
|
||||||
|
* @see Server
|
||||||
|
*/
|
||||||
Server getServer(Long id);
|
Server getServer(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restarts a server.
|
||||||
|
*
|
||||||
|
* @return State of the server.
|
||||||
|
*/
|
||||||
ServerInfo restartServer(Long id);
|
ServerInfo restartServer(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroys a server. This an async operation.
|
||||||
|
*
|
||||||
|
* @return A list of messages that have something to do with the shutdown. Can ignore safely.
|
||||||
|
*/
|
||||||
List<String> destroyServer(Long id);
|
List<String> destroyServer(Long id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.jclouds.rimuhosting.miro.binder;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
|
@ -31,15 +32,30 @@ import org.jclouds.rimuhosting.miro.domain.MetaData;
|
||||||
/**
|
/**
|
||||||
* @author Ivan Meredith
|
* @author Ivan Meredith
|
||||||
*/
|
*/
|
||||||
public class RimuHostingCreateInstanceBinder extends RimuHostingJsonBinder{
|
public class CreateServerOptions extends RimuHostingJsonBinder{
|
||||||
|
|
||||||
|
private String password;
|
||||||
|
private List<MetaData> metaData = new ArrayList<MetaData>();
|
||||||
|
|
||||||
|
@Override
|
||||||
public void bindToRequest(HttpRequest request, Map<String, String> postParams) {
|
public void bindToRequest(HttpRequest request, Map<String, String> postParams) {
|
||||||
String name = checkNotNull(postParams.get("name"));
|
String name = checkNotNull(postParams.get("name"));
|
||||||
String imageId = checkNotNull(postParams.get("imageId"));
|
String imageId = checkNotNull(postParams.get("imageId"));
|
||||||
String planId = checkNotNull(postParams.get("planId"));
|
String planId = checkNotNull(postParams.get("planId"));
|
||||||
//There will be cases when the password is null.
|
//There will be cases when the password is null.
|
||||||
String password = postParams.get("password");
|
String password = this.password;
|
||||||
NewServerData newServerData = new NewServerData(new CreateOptions(name, password, imageId), planId);
|
NewServerData newServerData = new NewServerData(new CreateOptions(name, password, imageId), planId);
|
||||||
newServerData.setMetaData(new ArrayList<MetaData>());
|
newServerData.setMetaData(metaData);
|
||||||
bindToRequest(request, newServerData);
|
bindToRequest(request, newServerData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CreateServerOptions withPassword(String password){
|
||||||
|
this.password = password;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreateServerOptions withMetaData(List<MetaData> metaData){
|
||||||
|
this.metaData = metaData;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rimuhosting.miro.domain;
|
package org.jclouds.rimuhosting.miro.domain;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
import org.jclouds.rimuhosting.miro.data.NewServerData;
|
import org.jclouds.rimuhosting.miro.data.NewServerData;
|
||||||
import org.jclouds.rimuhosting.miro.domain.internal.RunningState;
|
import org.jclouds.rimuhosting.miro.domain.internal.RunningState;
|
||||||
|
@ -30,11 +32,8 @@ import org.jclouds.rimuhosting.miro.domain.internal.RunningState;
|
||||||
*/
|
*/
|
||||||
public class Server implements Comparable<Server> {
|
public class Server implements Comparable<Server> {
|
||||||
|
|
||||||
|
|
||||||
@SerializedName("allocated_ips")
|
@SerializedName("allocated_ips")
|
||||||
private IpAddresses ipAddresses;
|
private IpAddresses ipAddresses;
|
||||||
// @SerializedName("billing_info")
|
|
||||||
// private BillingData billingData;
|
|
||||||
@SerializedName("billing_oid")
|
@SerializedName("billing_oid")
|
||||||
private Long billingId;
|
private Long billingId;
|
||||||
@SerializedName("data_transfer_allowance")
|
@SerializedName("data_transfer_allowance")
|
||||||
|
@ -60,6 +59,8 @@ public class Server implements Comparable<Server> {
|
||||||
|
|
||||||
private DataCenter location;
|
private DataCenter location;
|
||||||
|
|
||||||
|
@SerializedName("meta_data")
|
||||||
|
private List<MetaData> metaData;
|
||||||
//Object returned back with
|
//Object returned back with
|
||||||
private transient NewServerData serverDataRequest;
|
private transient NewServerData serverDataRequest;
|
||||||
|
|
||||||
|
@ -72,14 +73,6 @@ public class Server implements Comparable<Server> {
|
||||||
this.ipAddresses = ipAddresses;
|
this.ipAddresses = ipAddresses;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public BillingData getBillingData() {
|
|
||||||
// return billingData;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void setBillingData(BillingData billingData) {
|
|
||||||
// this.billingData = billingData;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public Long getBillingId() {
|
public Long getBillingId() {
|
||||||
return billingId;
|
return billingId;
|
||||||
}
|
}
|
||||||
|
@ -188,4 +181,12 @@ public class Server implements Comparable<Server> {
|
||||||
public DataCenter getLocation() {
|
public DataCenter getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMetaData(List<MetaData> metaData) {
|
||||||
|
this.metaData = metaData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MetaData> getMetaData() {
|
||||||
|
return metaData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue