openstack-glance extensibility

This commit is contained in:
Andrew Donald Kennedy 2012-08-12 12:42:22 +01:00
parent 9acfa880d4
commit b3121b7889
4 changed files with 26 additions and 11 deletions

View File

@ -44,12 +44,12 @@ public interface ImageApi {
/** /**
* Returns a set of brief metadata about images * Returns a set of brief metadata about images
*/ */
Set<Image> list(ListImageOptions... options); Set<? extends Image> list(ListImageOptions... options);
/** /**
* Returns a set of detailed metadata about images * Returns a set of detailed metadata about images
*/ */
Set<ImageDetails> listInDetail(ListImageOptions... options); Set<? extends ImageDetails> listInDetail(ListImageOptions... options);
/** /**
* Return metadata about an image with id * Return metadata about an image with id

View File

@ -73,7 +73,7 @@ public interface ImageAsyncApi {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Path("/images") @Path("/images")
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<Image>> list(ListImageOptions... options); ListenableFuture<? extends Set<? extends Image>> list(ListImageOptions... options);
/** /**
* @see ImageApi#listInDetail * @see ImageApi#listInDetail
@ -83,7 +83,7 @@ public interface ImageAsyncApi {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Path("/images/detail") @Path("/images/detail")
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
ListenableFuture<Set<ImageDetails>> listInDetail(ListImageOptions... options); ListenableFuture<? extends Set<? extends ImageDetails>> listInDetail(ListImageOptions... options);
/** /**
* @see ImageApi#show * @see ImageApi#show
@ -110,7 +110,7 @@ public interface ImageAsyncApi {
@Produces(MediaType.APPLICATION_OCTET_STREAM) @Produces(MediaType.APPLICATION_OCTET_STREAM)
@SelectJson("image") @SelectJson("image")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<ImageDetails> create(@HeaderParam("x-image-meta-name") String name, Payload payload, CreateImageOptions... options); ListenableFuture<? extends ImageDetails> create(@HeaderParam("x-image-meta-name") String name, Payload payload, CreateImageOptions... options);
/** /**
* @see ImageApi#reserve * @see ImageApi#reserve
@ -119,7 +119,7 @@ public interface ImageAsyncApi {
@Path("/images") @Path("/images")
@SelectJson("image") @SelectJson("image")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<ImageDetails> reserve(@HeaderParam("x-image-meta-name") String name, CreateImageOptions... options); ListenableFuture<? extends ImageDetails> reserve(@HeaderParam("x-image-meta-name") String name, CreateImageOptions... options);
/** /**
* @see ImageApi#upload * @see ImageApi#upload
@ -129,7 +129,7 @@ public interface ImageAsyncApi {
@Produces(MediaType.APPLICATION_OCTET_STREAM) @Produces(MediaType.APPLICATION_OCTET_STREAM)
@SelectJson("image") @SelectJson("image")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<ImageDetails> upload(@PathParam("id") String id, Payload imageData, UpdateImageOptions... options); ListenableFuture<? extends ImageDetails> upload(@PathParam("id") String id, Payload imageData, UpdateImageOptions... options);
/** /**
* @see ImageApi#update * @see ImageApi#update
@ -138,7 +138,7 @@ public interface ImageAsyncApi {
@Path("/images/{id}") @Path("/images/{id}")
@SelectJson("image") @SelectJson("image")
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
ListenableFuture<ImageDetails> update(@PathParam("id") String id, UpdateImageOptions... options); ListenableFuture<? extends ImageDetails> update(@PathParam("id") String id, UpdateImageOptions... options);
/** /**
* @see ImageApi#delete * @see ImageApi#delete

View File

@ -18,7 +18,21 @@
*/ */
package org.jclouds.openstack.glance.v1_0.functions; package org.jclouds.openstack.glance.v1_0.functions;
import static org.jclouds.openstack.glance.v1_0.options.ImageField.*; import static org.jclouds.openstack.glance.v1_0.options.ImageField.CHECKSUM;
import static org.jclouds.openstack.glance.v1_0.options.ImageField.CONTAINER_FORMAT;
import static org.jclouds.openstack.glance.v1_0.options.ImageField.CREATED_AT;
import static org.jclouds.openstack.glance.v1_0.options.ImageField.DELETED_AT;
import static org.jclouds.openstack.glance.v1_0.options.ImageField.DISK_FORMAT;
import static org.jclouds.openstack.glance.v1_0.options.ImageField.ID;
import static org.jclouds.openstack.glance.v1_0.options.ImageField.IS_PUBLIC;
import static org.jclouds.openstack.glance.v1_0.options.ImageField.LOCATION;
import static org.jclouds.openstack.glance.v1_0.options.ImageField.MIN_DISK;
import static org.jclouds.openstack.glance.v1_0.options.ImageField.MIN_RAM;
import static org.jclouds.openstack.glance.v1_0.options.ImageField.NAME;
import static org.jclouds.openstack.glance.v1_0.options.ImageField.OWNER;
import static org.jclouds.openstack.glance.v1_0.options.ImageField.SIZE;
import static org.jclouds.openstack.glance.v1_0.options.ImageField.STATUS;
import static org.jclouds.openstack.glance.v1_0.options.ImageField.UPDATED_AT;
import javax.inject.Inject; import javax.inject.Inject;
@ -44,6 +58,7 @@ public class ParseImageDetailsFromHeaders implements Function<HttpResponse, Imag
this.dateService = dateService; this.dateService = dateService;
} }
@Override
public ImageDetails apply(HttpResponse from) { public ImageDetails apply(HttpResponse from) {
ImageDetails.Builder<?> builder = ImageDetails.builder() ImageDetails.Builder<?> builder = ImageDetails.builder()
.id(from.getFirstHeaderOrNull(ID.asHeader())) .id(from.getFirstHeaderOrNull(ID.asHeader()))

View File

@ -49,7 +49,7 @@ public class ImageApiLiveTest extends BaseGlanceApiLiveTest {
public void testList() throws Exception { public void testList() throws Exception {
for (String zoneId : glanceContext.getApi().getConfiguredRegions()) { for (String zoneId : glanceContext.getApi().getConfiguredRegions()) {
ImageApi api = glanceContext.getApi().getImageApiForRegion(zoneId); ImageApi api = glanceContext.getApi().getImageApiForRegion(zoneId);
Set<Image> response = api.list(ListImageOptions.Builder.limit(100)); Set<? extends Image> response = api.list(ListImageOptions.Builder.limit(100));
assert null != response; assert null != response;
for (Image image : response) { for (Image image : response) {
checkImage(image); checkImage(image);
@ -67,7 +67,7 @@ public class ImageApiLiveTest extends BaseGlanceApiLiveTest {
public void testListInDetail() throws Exception { public void testListInDetail() throws Exception {
for (String zoneId : glanceContext.getApi().getConfiguredRegions()) { for (String zoneId : glanceContext.getApi().getConfiguredRegions()) {
ImageApi api = glanceContext.getApi().getImageApiForRegion(zoneId); ImageApi api = glanceContext.getApi().getImageApiForRegion(zoneId);
Set<ImageDetails> response = api.listInDetail(); Set<? extends ImageDetails> response = api.listInDetail();
assert null != response; assert null != response;
for (ImageDetails image : response) { for (ImageDetails image : response) {
checkImage(image); checkImage(image);