update client to use references, pathparams, etc.

This commit is contained in:
danikov 2012-02-13 16:44:26 +00:00
parent 35318568b0
commit 336c780713
2 changed files with 36 additions and 32 deletions

View File

@ -18,27 +18,28 @@
*/ */
package org.jclouds.vcloud.director.v1_5.features; package org.jclouds.vcloud.director.v1_5.features;
import java.net.URI;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE; import javax.ws.rs.DELETE;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.POST; import javax.ws.rs.POST;
import javax.ws.rs.PUT; import javax.ws.rs.PUT;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.JAXBResponseParser;
import org.jclouds.rest.annotations.PayloadParam; import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.vcloud.director.v1_5.domain.Media; import org.jclouds.vcloud.director.v1_5.domain.Media;
import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.Owner;
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
import org.jclouds.vcloud.director.v1_5.functions.ReferenceToEndpoint;
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
@ -50,50 +51,50 @@ import com.google.common.util.concurrent.ListenableFuture;
public interface MediaAsyncClient { public interface MediaAsyncClient {
/** /**
* @see MediaClient#getMedia() * @see MediaClient#getMedia(ReferenceType)
*/ */
@GET @GET
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Media> getMedia(@EndpointParam URI mediaRef); ListenableFuture<Media> getMedia(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> mediaRef);
/** /**
* @see MediaClient#updateMedia() * @see MediaClient#updateMedia(ReferenceType, Media))
*/ */
@PUT @PUT
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> updateMedia(@EndpointParam URI mediaRef, ListenableFuture<Task> updateMedia(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> mediaRef,
@PayloadParam("Media") Media media); @PayloadParam("Media") Media media);
/** /**
* @see MediaClient#deleteMedia() * @see MediaClient#deleteMedia(ReferenceType))
*/ */
@DELETE @DELETE
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Void> deleteMedia(@EndpointParam URI mediaRef); ListenableFuture<Void> deleteMedia(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> mediaRef);
/** /**
* @see MediaClient#getMedia() * @see MediaClient#getOwner(ReferenceType)
*/ */
@GET @GET
@Path("/owner/") @Path("/owner")
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Owner> getOwner(@EndpointParam URI mediaRef); ListenableFuture<Owner> getOwner(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> mediaRef);
/** /**
* @see MediaClient#getMetadata() * @see MediaClient#getMetadata()
*/ */
@GET @GET
@Path("/metadata/") @Path("/metadata")
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Metadata> getMetadata(@EndpointParam URI mediaRef); ListenableFuture<Metadata> getMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> mediaRef);
/** /**
* @see MediaClient#updateMetadata() * @see MediaClient#updateMetadata()
@ -101,7 +102,7 @@ public interface MediaAsyncClient {
@POST @POST
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> updateMetadata(@EndpointParam URI mediaRef, ListenableFuture<Task> updateMetadata(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> mediaRef,
@PayloadParam("Metadata") Metadata metadata); @PayloadParam("Metadata") Metadata metadata);
/** /**
@ -110,8 +111,9 @@ public interface MediaAsyncClient {
@GET @GET
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<MetadataEntry> getMetadataEntry(@EndpointParam URI metaDataRef); ListenableFuture<MetadataEntry> getMetadataEntry(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> mediaRef,
@PathParam("key") String key);
/** /**
* @see MediaClient#updateMedia() * @see MediaClient#updateMedia()
@ -119,7 +121,8 @@ public interface MediaAsyncClient {
@PUT @PUT
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Task> updateMetadataEntry(@EndpointParam URI metaDataRef, ListenableFuture<Task> updateMetadataEntry(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> metaDataRef,
@PathParam("key") String key,
@PayloadParam("MetadataEntry") MetadataEntry metadataEntry); @PayloadParam("MetadataEntry") MetadataEntry metadataEntry);
/** /**
@ -128,6 +131,7 @@ public interface MediaAsyncClient {
@DELETE @DELETE
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
ListenableFuture<Void> deleteMetadataEntry(@EndpointParam URI metaDataRef); ListenableFuture<Void> deleteMetadataEntry(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> metaDataRef,
@PathParam("key") String key);
} }

View File

@ -18,7 +18,6 @@
*/ */
package org.jclouds.vcloud.director.v1_5.features; package org.jclouds.vcloud.director.v1_5.features;
import java.net.URI;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
@ -26,6 +25,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Media;
import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry; import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.Owner;
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.Task;
/** /**
@ -44,7 +44,7 @@ public interface MediaClient {
* *
* @return the media or null if not found * @return the media or null if not found
*/ */
Media getMedia(URI mediaRef); Media getMedia(ReferenceType<?> mediaRef);
/** /**
* Updates the name/description of a media. * Updates the name/description of a media.
@ -52,40 +52,40 @@ public interface MediaClient {
* @return a task. This operation is asynchronous and the user should monitor the returned * @return a task. This operation is asynchronous and the user should monitor the returned
* task status in order to check when it is completed. * task status in order to check when it is completed.
*/ */
Task updateMedia(URI mediaRef, Media media); Task updateMedia(ReferenceType<?> mediaRef, Media media);
/** /**
* Deletes a media. * Deletes a media.
*/ */
void deleteMedia(URI mediaRef); void deleteMedia(ReferenceType<?> mediaRef);
/** /**
* Retrieves an owner. * Retrieves an owner.
* *
* @return the owner or null if not found * @return the owner or null if not found
*/ */
Owner getOwner(URI mediaRef); Owner getOwner(ReferenceType<?> mediaRef);
/** /**
* Retrieves an list of the media's metadata * Retrieves an list of the media's metadata
* *
* @return a list of metadata * @return a list of metadata
*/ */
Metadata getMetadata(URI mediaRef); Metadata getMetadata(ReferenceType<?> mediaRef);
/** /**
* Merges the metadata for a media with the information provided. * Merges the metadata for a media with the information provided.
* *
* @return a task. This operation is asynchronous and the user should monitor the returned * @return a task. This operation is asynchronous and the user should monitor the returned
* task status in order to check when it is completed. * task status in order to check when it is completed.
*/ */
Task updateMetadata(URI mediaRef, Metadata metadata); Task updateMetadata(ReferenceType<?> mediaRef, Metadata metadata);
/** /**
* Retrieves a metadata entry * Retrieves a metadata entry
* *
* @return the metadata entry, or null if not found * @return the metadata entry, or null if not found
*/ */
MetadataEntry getMetadataEntry(URI metaDataRef); MetadataEntry getMetadataEntry(ReferenceType<?> mediaRef, String key);
/** /**
* Sets the metadata for the particular key for the media to the value provided * Sets the metadata for the particular key for the media to the value provided
@ -93,12 +93,12 @@ public interface MediaClient {
* @return a task. This operation is asynchronous and the user should monitor the returned * @return a task. This operation is asynchronous and the user should monitor the returned
* task status in order to check when it is completed. * task status in order to check when it is completed.
*/ */
Task updateMetadataEntry(URI metaDataRef, MetadataEntry metadataEntry); Task updateMetadataEntry(ReferenceType<?> mediaRef, String key, MetadataEntry metadataEntry);
/** /**
* Deletes a metadata entry. * Deletes a metadata entry.
*/ */
void deleteMetadataEntry(URI metaDataRef); void deleteMetadataEntry(ReferenceType<?> mediaRef, String key);
} }