Add Nova client get requests by uuid for retreiving Server, Flavor, and Image details.

This commit is contained in:
Matt Stephenson 2011-11-08 12:11:54 -06:00
parent dd5f343954
commit 3c803b3d8a
3 changed files with 82 additions and 1 deletions

View File

@ -73,6 +73,17 @@ public interface NovaAsyncClient {
@Path("/servers/{id}")
ListenableFuture<Server> getServer(@PathParam("id") int id);
/**
* @see NovaClient#getServer
*/
@GET
@Unwrap
@Consumes(MediaType.APPLICATION_JSON)
@QueryParams(keys = "format", values = "json")
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
@Path("/servers/{uuid}")
ListenableFuture<Server> getServer(@PathParam("uuid") String uuid);
/**
* @see NovaClient#deleteServer
*/
@ -183,6 +194,17 @@ public interface NovaAsyncClient {
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Flavor> getFlavor(@PathParam("id") int id);
/**
* @see NovaClient#getFlavor
*/
@GET
@Unwrap
@Consumes(MediaType.APPLICATION_JSON)
@QueryParams(keys = "format", values = "json")
@Path("/flavors/{uuid}")
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Flavor> getFlavor(@PathParam("uuid") String uuid);
/**
* @see NovaClient#listImages
*/
@ -205,6 +227,17 @@ public interface NovaAsyncClient {
@Path("/images/{id}")
ListenableFuture<Image> getImage(@PathParam("id") int id);
/**
* @see NovaClient#getImage
*/
@GET
@Unwrap
@Consumes(MediaType.APPLICATION_JSON)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
@QueryParams(keys = "format", values = "json")
@Path("/images/{uuid}")
ListenableFuture<Image> getImage(@PathParam("uuid") String uuid);
/**
* @see NovaClient#deleteImage
*/

View File

@ -70,7 +70,8 @@ public interface NovaClient {
* @return null, if the server is not found
* @see Server
*/
Server getServer(@PathParam("id") int id);
Server getServer(int id);
Server getServer(String uuid);
/**
*
@ -204,6 +205,7 @@ public interface NovaClient {
* @see Flavor
*/
Flavor getFlavor(int id);
Flavor getFlavor(String uuid);
/**
*
@ -223,6 +225,7 @@ public interface NovaClient {
* @see Image
*/
Image getImage(int id);
Image getImage(String id);
/**
*

View File

@ -212,6 +212,21 @@ public class NovaAsyncClientTest extends RestClientTest<NovaAsyncClient> {
checkFilters(request);
}
public void testGetServerByUUID() throws IOException, SecurityException, NoSuchMethodException {
Method method = NovaAsyncClient.class.getMethod("getServer", String.class);
HttpRequest request = processor.createRequest(method, "dfdcd0a6-0a2f-11e1-8505-2837371c69ae");
assertRequestLineEquals(request, "GET http://endpoint/vapiversion/servers/dfdcd0a6-0a2f-11e1-8505-2837371c69ae?format=json HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
}
public void testListFlavors() throws IOException, SecurityException, NoSuchMethodException {
Method method = NovaAsyncClient.class.getMethod("listFlavors", listOptionsVarargsClass);
HttpRequest request = processor.createRequest(method);
@ -289,6 +304,21 @@ public class NovaAsyncClientTest extends RestClientTest<NovaAsyncClient> {
checkFilters(request);
}
public void testGetFlavorByUUID() throws IOException, SecurityException, NoSuchMethodException {
Method method = NovaAsyncClient.class.getMethod("getFlavor", String.class);
HttpRequest request = processor.createRequest(method, "209904b6-0a30-11e1-a0f0-2837371c69ae");
assertRequestLineEquals(request, "GET http://endpoint/vapiversion/flavors/209904b6-0a30-11e1-a0f0-2837371c69ae?format=json HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
}
public void testListImages() throws IOException, SecurityException, NoSuchMethodException {
Method method = NovaAsyncClient.class.getMethod("listImages", listOptionsVarargsClass);
HttpRequest request = processor.createRequest(method);
@ -366,6 +396,21 @@ public class NovaAsyncClientTest extends RestClientTest<NovaAsyncClient> {
checkFilters(request);
}
public void testGetImageByUUID() throws IOException, SecurityException, NoSuchMethodException {
Method method = NovaAsyncClient.class.getMethod("getImage", int.class);
HttpRequest request = processor.createRequest(method, "3bd52d90-0a30-11e1-83f5-2837371c69ae");
assertRequestLineEquals(request, "GET http://endpoint/vapiversion/images/3bd52d90-0a30-11e1-83f5-2837371c69ae?format=json HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Accept: application/json\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, UnwrapOnlyJsonValue.class);
assertSaxResponseParserClassEquals(method, null);
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
checkFilters(request);
}
public void testDeleteServer() throws IOException, SecurityException, NoSuchMethodException {
Method method = NovaAsyncClient.class.getMethod("deleteServer", int.class);
HttpRequest request = processor.createRequest(method, 2);