From 5789d1783ee7cfe99b15e1c45e8ab389170f3554 Mon Sep 17 00:00:00 2001 From: danikov Date: Mon, 5 Mar 2012 10:52:04 +0000 Subject: [PATCH] test groupings + metadataclient delegation --- .../v1_5/VCloudDirectorAsyncClient.java | 10 +- .../director/v1_5/VCloudDirectorClient.java | 9 +- .../VCloudDirectorRestClientModule.java | 3 +- .../v1_5/features/CatalogAsyncClient.java | 81 +--------------- .../director/v1_5/features/CatalogClient.java | 93 +------------------ .../v1_5/features/MediaAsyncClient.java | 64 +------------ .../director/v1_5/features/MediaClient.java | 41 +------- .../v1_5/features/MetadataAsyncClient.java | 6 +- .../v1_5/features/MetadataClient.java | 15 +-- .../v1_5/features/NetworkAsyncClient.java | 25 +---- .../director/v1_5/features/NetworkClient.java | 17 +--- .../v1_5/features/OrgAsyncClient.java | 24 +---- .../director/v1_5/features/OrgClient.java | 24 +---- .../v1_5/features/VdcAsyncClient.java | 24 +---- .../director/v1_5/features/VdcClient.java | 16 +--- .../features/CatalogClientExpectTest.java | 14 +-- .../v1_5/features/CatalogClientLiveTest.java | 32 +++---- .../v1_5/features/MediaClientExpectTest.java | 12 +-- .../v1_5/features/MediaClientLiveTest.java | 24 ++--- .../features/NetworkClientExpectTest.java | 4 +- .../v1_5/features/NetworkClientLiveTest.java | 4 +- .../v1_5/features/OrgClientExpectTest.java | 4 +- .../v1_5/features/OrgClientLiveTest.java | 4 +- .../v1_5/features/VdcClientExpectTest.java | 4 +- .../v1_5/features/VdcClientLiveTest.java | 4 +- 25 files changed, 110 insertions(+), 448 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorAsyncClient.java index 94d1a9d70b..40bbac8771 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorAsyncClient.java @@ -21,20 +21,18 @@ package org.jclouds.vcloud.director.v1_5; import org.jclouds.rest.annotations.Delegate; import org.jclouds.vcloud.director.v1_5.domain.Catalog; 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.Org; import org.jclouds.vcloud.director.v1_5.domain.Session; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.Vdc; import org.jclouds.vcloud.director.v1_5.domain.ovf.Network; import org.jclouds.vcloud.director.v1_5.features.CatalogAsyncClient; -import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient; import org.jclouds.vcloud.director.v1_5.features.NetworkAsyncClient; import org.jclouds.vcloud.director.v1_5.features.OrgAsyncClient; import org.jclouds.vcloud.director.v1_5.features.QueryAsyncClient; import org.jclouds.vcloud.director.v1_5.features.TaskAsyncClient; -import org.jclouds.vcloud.director.v1_5.features.VAppTemplateAsyncClient; import org.jclouds.vcloud.director.v1_5.features.UploadAsyncClient; +import org.jclouds.vcloud.director.v1_5.features.VAppTemplateAsyncClient; import org.jclouds.vcloud.director.v1_5.features.VdcAsyncClient; import com.google.inject.Provides; @@ -101,11 +99,7 @@ public interface VCloudDirectorAsyncClient { @Delegate UploadAsyncClient getUploadClient(); - /** - * @return asynchronous access to {@link Metadata} features - */ - @Delegate - MetadataAsyncClient getMetadataClient(); + /** * @return asynchronous access to {@link org.jclouds.vcloud.director.v1_5.domain.VAppTemplate} features */ diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClient.java index 75094928ad..15d4195af1 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClient.java @@ -24,7 +24,6 @@ import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; import org.jclouds.vcloud.director.v1_5.domain.Catalog; 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.Org; import org.jclouds.vcloud.director.v1_5.domain.Session; import org.jclouds.vcloud.director.v1_5.domain.Task; @@ -32,13 +31,12 @@ import org.jclouds.vcloud.director.v1_5.domain.Vdc; import org.jclouds.vcloud.director.v1_5.domain.ovf.Network; import org.jclouds.vcloud.director.v1_5.features.CatalogClient; import org.jclouds.vcloud.director.v1_5.features.MediaClient; -import org.jclouds.vcloud.director.v1_5.features.MetadataClient; import org.jclouds.vcloud.director.v1_5.features.NetworkClient; import org.jclouds.vcloud.director.v1_5.features.OrgClient; import org.jclouds.vcloud.director.v1_5.features.QueryClient; import org.jclouds.vcloud.director.v1_5.features.TaskClient; -import org.jclouds.vcloud.director.v1_5.features.VAppTemplateClient; import org.jclouds.vcloud.director.v1_5.features.UploadClient; +import org.jclouds.vcloud.director.v1_5.features.VAppTemplateClient; import org.jclouds.vcloud.director.v1_5.features.VdcClient; import com.google.inject.Provides; @@ -106,11 +104,6 @@ public interface VCloudDirectorClient { UploadClient getUploadClient(); /** - * @return synchronous access to {@link Metadata} features - */ - @Delegate - MetadataClient getMetadataClient(); - /* * @return synchronous access to {@link org.jclouds.vcloud.director.v1_5.domain.VAppTemplate} features */ @Delegate diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java index 5c39b4a14a..7163767131 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/config/VCloudDirectorRestClientModule.java @@ -83,7 +83,8 @@ public class VCloudDirectorRestClientModule extends RestClientModule addCatalogItem(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogRef, @BinderParam(BindToXMLPayload.class) CatalogItem catalogItem); - /** - * Returns the metadata associated with the catalog. - */ - @GET - @Path("/metadata") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getCatalogMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogRef); - - /** - * Returns the metadata associated with the catalog for the specified key. - */ - @GET - @Path("/metadata/{key}") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getCatalogMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogRef, - @PathParam("key") String key); - /** * Retrieves a catalog item. */ @@ -125,58 +102,8 @@ public interface CatalogAsyncClient { ListenableFuture deleteCatalogItem(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogItemRef); /** - * Returns the metadata associated with the catalog item. + * @return asynchronous access to {@link Metadata.Writeable} features */ - @GET - @Path("/metadata") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getCatalogItemMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogItemRef); - - /** - * Merges the metadata for a catalog item with the information provided. - */ - @POST - @Path("/metadata") - @Consumes(VCloudDirectorMediaType.TASK) - @Produces(VCloudDirectorMediaType.METADATA) - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture mergeCatalogItemMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogItemRef, - @BinderParam(BindToXMLPayload.class) Metadata catalogItemMetadata); - - /** - * Returns the metadata associated with the catalog item for the specified key. - */ - @GET - @Path("/metadata/{key}") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getCatalogItemMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogItemRef, - @PathParam("key") String key); - - /** - * Sets the metadata for the particular key for the catalog item to the value provided. - */ - @PUT - @Path("/metadata/{key}") - @Consumes(VCloudDirectorMediaType.TASK) - @Produces(VCloudDirectorMediaType.METADATA_VALUE) - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture setCatalogItemMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogItemRef, - @PathParam("key") String key, @BinderParam(BindToXMLPayload.class) MetadataValue metadataValue); - - /** - * Deletes the metadata for the particular key for the catalog item. - */ - @DELETE - @Path("/metadata/{key}") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture deleteCatalogItemMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier catalogItemRef, - @PathParam("key") String key); + @Delegate + MetadataAsyncClient.Writable getMetadataClient(); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogClient.java index da583f3f45..9fc27f23de 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogClient.java @@ -21,11 +21,10 @@ package org.jclouds.vcloud.director.v1_5.features; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; +import org.jclouds.rest.annotations.Delegate; import org.jclouds.vcloud.director.v1_5.domain.Catalog; import org.jclouds.vcloud.director.v1_5.domain.CatalogItem; import org.jclouds.vcloud.director.v1_5.domain.Metadata; -import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; -import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.URISupplier; /** @@ -62,31 +61,6 @@ public interface CatalogClient { */ CatalogItem addCatalogItem(URISupplier catalogRef, CatalogItem item); - /** - * Returns the metadata associated with the catalog. - * - *
-    * GET /catalog/{id}/metadata
-    * 
- * - * @param catalogRef the reference for the catalog - * @return the catalog metadata - */ - Metadata getCatalogMetadata(URISupplier catalogRef); - - /** - * Returns the metadata associated with the catalog for the specified key. - * - *
-    * GET /catalog/{id}/metadata/{key}
-    * 
- * - * @param catalogRef the reference for the catalog - * @param key the metadata entry key - * @return the catalog metadata value - */ - MetadataValue getCatalogMetadataValue(URISupplier catalogRef, String key); - /** * Retrieves a catalog item. * @@ -124,67 +98,8 @@ public interface CatalogClient { void deleteCatalogItem(URISupplier catalogItemRef); /** - * Returns the metadata associated with the catalog item. - * - *
-    * GET /catalogItem/{id}/metadata
-    * 
- * - * @param catalogItemRef the reference for the catalog item - * @return the catalog item metadata + * @return synchronous access to {@link Metadata.Writeable} features */ - Metadata getCatalogItemMetadata(URISupplier catalogItemRef); - - /** - * Merges the metadata for a catalog item with the information provided. - * - *
-    * POST /catalogItem/{id}/metadata
-    * 
- * - * @param catalogItemRef the reference for the catalog item - * @param catalogItemMetadata the metadata for the catalog item - * @return a task for the merge operation - */ - Task mergeCatalogItemMetadata(URISupplier catalogItemRef, Metadata catalogItemMetadata); - - /** - * Returns the metadata associated with the catalog item for the specified key. - * - *
-    * GET /catalog/{id}/metadata/{key}
-    * 
- * - * @param catalogItemRef the reference for the catalog item - * @param key the metadata entry key - * @return the catalog item metadata value - */ - MetadataValue getCatalogItemMetadataValue(URISupplier catalogItemRef, String key); - - /** - * Sets the metadata for the particular key for the catalog item to the value provided. - * - *
-    * PUT /catalog/{id}/metadata/{key}
-    * 
- * - * @param catalogItemRef the reference for the catalog item - * @param key the metadata entry key - * @param value the metadata value - * @return a task for the set operation - */ - Task setCatalogItemMetadataValue(URISupplier catalogItemRef, String key, MetadataValue value); - - /** - * Deletes the metadata for the particular key for the catalog item. - * - *
-    * DELETE /catalog/{id}/metadata/{key}
-    * 
- * - * @param catalogItemRef the reference for the catalog item - * @param key the metadata entry key - * @return a task for the delete operation - */ - Task deleteCatalogItemMetadataValue(URISupplier catalogItemRef, String key); + @Delegate + MetadataClient.Writeable getMetadataClient(); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaAsyncClient.java index 3bd49792ab..4c28188b6e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaAsyncClient.java @@ -21,13 +21,12 @@ package org.jclouds.vcloud.director.v1_5.features; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; -import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; -import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.JAXBResponseParser; @@ -36,7 +35,6 @@ import org.jclouds.rest.binders.BindToXMLPayload; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; 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.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.URISupplier; @@ -93,60 +91,8 @@ public interface MediaAsyncClient { ListenableFuture getOwner(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier mediaRef); /** - * @see MediaClient#getMetadata(URISupplier)) - */ - @GET - @Path("/metadata") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier mediaRef); - - /** - * @see MediaClient#mergeMetadata(URISupplier, Metadata)) - */ - @POST - @Path("/metadata") - @Consumes(VCloudDirectorMediaType.TASK) - @Produces(VCloudDirectorMediaType.METADATA) - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture mergeMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier mediaRef, - @BinderParam(BindToXMLPayload.class) Metadata metadata); - - /** - * @see MediaClient#getMetadataEntry(URISupplier, String)) - */ - @GET - @Path("/metadata/{key}") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier mediaRef, - @PathParam("key") String key); - - /** - * @see MediaClient#setMetadata(URISupplier, String, MetadataEntry)) - */ - @PUT - @Path("/metadata/{key}") - @Consumes(VCloudDirectorMediaType.TASK) - @Produces(VCloudDirectorMediaType.METADATA_VALUE) - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture setMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier metaDataRef, - @PathParam("key") String key, - @BinderParam(BindToXMLPayload.class) MetadataValue metadataValue); - - /** - * @see MediaClient#deleteMetadataEntry(URISupplier, String)) - */ - @DELETE - @Path("/metadata/{key}") - @Consumes(VCloudDirectorMediaType.TASK) - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture deleteMetadataEntry(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier metaDataRef, - @PathParam("key") String key); - + * @return asynchronous access to {@link Metadata.Writeable} features + */ + @Delegate + MetadataAsyncClient.Writable getMetadataClient(); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaClient.java index 4a55b7bdd5..7f19e85b52 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaClient.java @@ -21,9 +21,9 @@ package org.jclouds.vcloud.director.v1_5.features; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; +import org.jclouds.rest.annotations.Delegate; 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.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.URISupplier; @@ -67,42 +67,9 @@ public interface MediaClient { Owner getOwner(URISupplier mediaRef); /** - * Retrieves an list of the media's metadata - * - * @return a list of metadata + * @return synchronous access to {@link Metadata.Writeable} features */ - Metadata getMetadata(URISupplier mediaRef); - /** - * Merges the metadata for a media with the information provided. - * - * @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 mergeMetadata(URISupplier mediaRef, Metadata metadata); - - /** - * Retrieves a metadata value - * - * @return the metadata value, or null if not found - */ - MetadataValue getMetadataValue(URISupplier mediaRef, String key); - - /** - * Sets the metadata for the particular key for the media to the value provided. - * Note: this will replace any existing metadata information - * - * @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 setMetadata(URISupplier mediaRef, String key, MetadataValue metadataValue); - - /** - * Deletes a metadata entry. - * - * @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 deleteMetadataEntry(URISupplier mediaRef, String key); - + @Delegate + MetadataClient.Writeable getMetadataClient(); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataAsyncClient.java index b1a4341288..1998a8bd2e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataAsyncClient.java @@ -60,7 +60,7 @@ public interface MetadataAsyncClient { @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier parent); + ListenableFuture getMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier parentRef); /** * @see MetadataClient.Readable#getMetadataEntry(URISupplier, String) @@ -70,7 +70,7 @@ public interface MetadataAsyncClient { @Consumes @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier parent , + ListenableFuture getMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier parentRef , @PathParam("key") String key); } @@ -84,7 +84,7 @@ public interface MetadataAsyncClient { @Produces(VCloudDirectorMediaType.METADATA) @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture mergeMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier mediaRef, + ListenableFuture mergeMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier parentRef, @BinderParam(BindToXMLPayload.class) Metadata metadata); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataClient.java index 90842c8ab3..5d31ff3b4e 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataClient.java @@ -34,32 +34,33 @@ import org.jclouds.vcloud.director.v1_5.domain.URISupplier; * @see * @author danikov */ -@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS) public interface MetadataClient { + @Timeout(duration = 180, timeUnit = TimeUnit.SECONDS) public static interface Readable extends MetadataClient { /** * Retrieves an list of metadata * * @return a list of metadata */ - Metadata getMetadata(URISupplier vdcRef); + Metadata getMetadata(URISupplier parentRef); /** * Retrieves a metadata value * * @return the metadata value, or null if not found */ - MetadataValue getMetadataValue(URISupplier vdcRef, String key); + MetadataValue getMetadataValue(URISupplier parentRef, String key); } - public static interface Writable extends Readable { + @Timeout(duration = 180, timeUnit = TimeUnit.SECONDS) + public static interface Writeable extends Readable { /** * Merges the metadata for a media with the information provided. * * @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 mergeMetadata(URISupplier mediaRef, Metadata metadata); + Task mergeMetadata(URISupplier parentRef, Metadata metadata); /** * Sets the metadata for the particular key for the media to the value provided. @@ -68,7 +69,7 @@ public interface MetadataClient { * @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 setMetadata(URISupplier mediaRef, String key, MetadataValue metadataValue); + Task setMetadata(URISupplier parentRef, String key, MetadataValue metadataValue); /** * Deletes a metadata entry. @@ -76,6 +77,6 @@ public interface MetadataClient { * @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 deleteMetadataEntry(URISupplier mediaRef, String key); + Task deleteMetadataEntry(URISupplier parentRef, String key); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkAsyncClient.java index 7681d80660..c1121c7c50 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkAsyncClient.java @@ -20,15 +20,13 @@ package org.jclouds.vcloud.director.v1_5.features; import javax.ws.rs.Consumes; import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; +import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.vcloud.director.v1_5.domain.Metadata; -import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork; import org.jclouds.vcloud.director.v1_5.domain.URISupplier; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; @@ -55,24 +53,9 @@ public interface NetworkAsyncClient { ListenableFuture getNetwork(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier networkRef); /** - * @see NeworkClient#getMetadata(URISupplier) + * @return asynchronous access to {@link Metadata.Readable} features */ - @GET - @Path("/metadata") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier networkRef); - - /** - * @see NeworkClient#getMetadataValue(URISupplier, String) - */ - @GET - @Path("/metadata/{key}") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier networkRef , - @PathParam("key") String key); + @Delegate + MetadataAsyncClient.Readable getMetadataClient(); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkClient.java index 7fbb6859c2..2cf8e2239a 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkClient.java @@ -21,8 +21,8 @@ package org.jclouds.vcloud.director.v1_5.features; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; +import org.jclouds.rest.annotations.Delegate; import org.jclouds.vcloud.director.v1_5.domain.Metadata; -import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork; import org.jclouds.vcloud.director.v1_5.domain.URISupplier; @@ -45,17 +45,8 @@ public interface NetworkClient { OrgNetwork getNetwork(URISupplier networkRef); /** - * Retrieves an list of the network's metadata - * - * @return a list of metadata + * @return synchronous access to {@link Metadata.Readable} features */ - Metadata getMetadata(URISupplier networkRef); - - /** - * Retrieves a metadata value - * - * @return the metadata value, or null if not found - */ - MetadataValue getMetadataValue(URISupplier networkRef, String key); - + @Delegate + MetadataClient.Readable getMetadataClient(); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncClient.java index d3437511ef..57f647074c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncClient.java @@ -21,14 +21,13 @@ package org.jclouds.vcloud.director.v1_5.features; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.Path; -import javax.ws.rs.PathParam; +import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.vcloud.director.v1_5.domain.Metadata; -import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.Org; import org.jclouds.vcloud.director.v1_5.domain.OrgList; import org.jclouds.vcloud.director.v1_5.domain.ReferenceType; @@ -65,23 +64,8 @@ public interface OrgAsyncClient { ListenableFuture getOrg(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier orgRef); /** - * @see OrgClient#getMetadata(ReferenceType) + * @return asynchronous access to {@link Metadata.Readable} features */ - @GET - @Path("/metadata") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getOrgMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier orgRef); - - /** - * @see OrgClient#getMetadataEntry(ReferenceType, String) - */ - @GET - @Path("/metadata/{key}") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getOrgMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier orgRef, - @PathParam("key") String key); + @Delegate + MetadataAsyncClient.Readable getMetadataClient(); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgClient.java index d297c21b17..1a954f3893 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgClient.java @@ -21,8 +21,8 @@ package org.jclouds.vcloud.director.v1_5.features; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; +import org.jclouds.rest.annotations.Delegate; import org.jclouds.vcloud.director.v1_5.domain.Metadata; -import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.Org; import org.jclouds.vcloud.director.v1_5.domain.OrgList; import org.jclouds.vcloud.director.v1_5.domain.URISupplier; @@ -60,24 +60,8 @@ public interface OrgClient { Org getOrg(URISupplier orgRef); /** - * Retrieves an list of the organization's metadata - * - *
-    * GET /org/{id}/metadata
-    * 
- * - * @return a list of metadata + * @return synchronous access to {@link Metadata.Readable} features */ - Metadata getOrgMetadata(URISupplier orgRef); - - /** - * Retrieves a metadata entry. - * - *
-    * GET /org/{id}/metadata{key}
-    * 
- * - * @return the metadata entry or null if not found - */ - MetadataValue getOrgMetadataValue(URISupplier orgRef, String key); + @Delegate + MetadataClient.Readable getMetadataClient(); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java index 1089d68647..100692c8cb 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncClient.java @@ -22,10 +22,10 @@ import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; -import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.JAXBResponseParser; @@ -40,7 +40,6 @@ import org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams; import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppParamsType; 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.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.URISupplier; import org.jclouds.vcloud.director.v1_5.domain.UploadVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.VApp; @@ -166,24 +165,9 @@ public interface VdcAsyncClient { @BinderParam(BindToXMLPayload.class) Media media); /** - * @see VdcClient#getMetadata(URISupplier) + * @return asynchronous access to {@link Metadata.Readable} features */ - @GET - @Path("/metadata") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getMetadata(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier vdcRef); - - /** - * @see VdcClient#getMetadataEntry(URISupplier, String) - */ - @GET - @Path("/metadata/{key}") - @Consumes - @JAXBResponseParser - @ExceptionParser(ThrowVCloudErrorOn4xx.class) - ListenableFuture getMetadataValue(@EndpointParam(parser = URISupplierToEndpoint.class) URISupplier vdcRef , - @PathParam("key") String key); + @Delegate + MetadataAsyncClient.Readable getMetadataClient(); } \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java index edc48e8108..7a20e21fe0 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcClient.java @@ -21,6 +21,7 @@ package org.jclouds.vcloud.director.v1_5.features; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; +import org.jclouds.rest.annotations.Delegate; import org.jclouds.vcloud.director.v1_5.domain.CaptureVAppParams; import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams; import org.jclouds.vcloud.director.v1_5.domain.CloneVAppParams; @@ -29,7 +30,6 @@ import org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams; import org.jclouds.vcloud.director.v1_5.domain.InstantiateVAppParamsType; 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.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.URISupplier; import org.jclouds.vcloud.director.v1_5.domain.UploadVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.VApp; @@ -144,17 +144,9 @@ public interface VdcClient { Media createMedia(URISupplier vdcRef, Media media); /** - * Retrieves an list of the vdc's metadata - * - * @return a list of metadata + * @return synchronous access to {@link Metadata.Readable} features */ - Metadata getMetadata(URISupplier vdcRef); - - /** - * Retrieves a metadata value - * - * @return the metadata value, or null if not found - */ - MetadataValue getMetadataValue(URISupplier vdcRef, String key); + @Delegate + MetadataClient.Readable getMetadataClient(); } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java index 18cf10c3e4..e0e1cbe1ee 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientExpectTest.java @@ -149,7 +149,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT .entries(ImmutableSet.of(metadataEntry())) .build(); - assertEquals(client.getCatalogClient().getCatalogMetadata(catalogRef), expected); + assertEquals(client.getCatalogClient().getMetadataClient().getMetadata(catalogRef), expected); } @Test @@ -178,7 +178,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT MetadataValue expected = metadataValue(); - assertEquals(client.getCatalogClient().getCatalogMetadataValue(catalogRef, "KEY"), expected); + assertEquals(client.getCatalogClient().getMetadataClient().getMetadataValue(catalogRef, "KEY"), expected); } @Test @@ -301,7 +301,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT .entries(ImmutableSet.of(itemMetadataEntry())) .build(); - assertEquals(client.getCatalogClient().getCatalogItemMetadata(catalogItemReference), expected); + assertEquals(client.getCatalogClient().getMetadataClient().getMetadata(catalogItemReference), expected); } @Test @@ -333,7 +333,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT Task expected = mergeMetadataTask(); - assertEquals(client.getCatalogClient().mergeCatalogItemMetadata(catalogItemReference, metadata), expected); + assertEquals(client.getCatalogClient().getMetadataClient().mergeMetadata(catalogItemReference, metadata), expected); } @Test @@ -362,7 +362,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT MetadataValue expected = itemMetadataValue(); - assertEquals(client.getCatalogClient().getCatalogItemMetadataValue(catalogItemReference, "KEY"), expected); + assertEquals(client.getCatalogClient().getMetadataClient().getMetadataValue(catalogItemReference, "KEY"), expected); } @Test @@ -394,7 +394,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT Task expected = setMetadataValueTask(); - assertEquals(client.getCatalogClient().setCatalogItemMetadataValue(catalogItemReference, "KEY", value), expected); + assertEquals(client.getCatalogClient().getMetadataClient().setMetadata(catalogItemReference, "KEY", value), expected); } @Test @@ -423,7 +423,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT Task expected = deleteMetadataEntryTask(); - assertEquals(client.getCatalogClient().deleteCatalogItemMetadataValue(catalogItemReference, "KEY"), expected); + assertEquals(client.getCatalogClient().getMetadataClient().deleteMetadataEntry(catalogItemReference, "KEY"), expected); } public static final Catalog catalog() { diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java index a01e021db6..7cdf8e37f9 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogClientLiveTest.java @@ -150,7 +150,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { // NOTE for this test to work, we need to be able to create metadata on a Catalog, specifically { "KEY", "VALUE" } @Test(testName = "GET /catalog/{id}/metadata", dependsOnMethods = { "testGetCatalog" }, enabled = false) public void testGetCatalogMetadata() { - catalogMetadata = catalogClient.getCatalogMetadata(catalogRef); + catalogMetadata = catalogClient.getMetadataClient().getMetadata(catalogRef); checkMetadata(catalogMetadata); } @@ -163,7 +163,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { return input.getKey().equals("KEY"); } }); - MetadataValue metadataValue = catalogClient.getCatalogMetadataValue(catalogRef, "KEY"); + MetadataValue metadataValue = catalogClient.getMetadataClient().getMetadataValue(catalogRef, "KEY"); assertEquals(metadataValue.getValue(), existingMetadataEntry.getValue(), String.format(CORRECT_VALUE_OBJECT_FMT, "Value", "MetadataValue", existingMetadataEntry.getValue(), metadataValue.getValue())); checkMetadataValue(metadataValue); @@ -172,7 +172,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(testName = "GET /catalogItem/{id}/metadata", dependsOnMethods = { "testGetCatalogItem" }) public void testGetCatalogItemMetadata() { resetCatalogItemMetadata(catalogItemRef); - catalogItemMetadata = catalogClient.getCatalogItemMetadata(catalogItemRef); + catalogItemMetadata = catalogClient.getMetadataClient().getMetadata(catalogItemRef); assertEquals(catalogItemMetadata.getMetadataEntries().size(), 1, String.format(MUST_EXIST_FMT, "MetadataEntry", "CatalogItem")); checkMetadata(catalogItemMetadata); } @@ -184,22 +184,22 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { .entry(MetadataEntry.builder().entry("VEGIMITE", "VALUE").build()) .build(); - Task mergeCatalogItemMetadata = catalogClient.mergeCatalogItemMetadata(catalogItemRef, newMetadata); + Task mergeCatalogItemMetadata = catalogClient.getMetadataClient().mergeMetadata(catalogItemRef, newMetadata); checkTask(mergeCatalogItemMetadata); assertTrue(retryTaskSuccess.apply(mergeCatalogItemMetadata), String.format(TASK_COMPLETE_TIMELY, "mergeCatalogItemMetadata")); - Metadata mergedCatalogItemMetadata = catalogClient.getCatalogItemMetadata(catalogItemRef); + Metadata mergedCatalogItemMetadata = catalogClient.getMetadataClient().getMetadata(catalogItemRef); // XXX assertEquals(mergedCatalogItemMetadata.getMetadataEntries().size(), catalogItemMetadata.getMetadataEntries().size() + 1, "Should have added another MetadataEntry to the CatalogItem"); - MetadataValue keyMetadataValue = catalogClient.getCatalogItemMetadataValue(catalogItemRef, "KEY"); + MetadataValue keyMetadataValue = catalogClient.getMetadataClient().getMetadataValue(catalogItemRef, "KEY"); // XXX assertEquals(keyMetadataValue.getValue(), "MARMALADE", "The Value of the MetadataValue for KEY should have changed"); checkMetadataValue(keyMetadataValue); - MetadataValue newKeyMetadataValue = catalogClient.getCatalogItemMetadataValue(catalogItemRef, "VEGIMITE"); + MetadataValue newKeyMetadataValue = catalogClient.getMetadataClient().getMetadataValue(catalogItemRef, "VEGIMITE"); // XXX assertEquals(newKeyMetadataValue.getValue(), "VALUE", "The Value of the MetadataValue for NEW_KEY should have been set"); checkMetadataValue(newKeyMetadataValue); @@ -215,7 +215,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { return input.getKey().equals("KEY"); } }); - MetadataValue metadataValue = catalogClient.getCatalogItemMetadataValue(catalogItemRef, "KEY"); + MetadataValue metadataValue = catalogClient.getMetadataClient().getMetadataValue(catalogItemRef, "KEY"); assertEquals(existingMetadataEntry.getValue(), metadataValue.getValue()); checkMetadataValue(metadataValue); } @@ -224,13 +224,13 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { public void testSetCatalogItemMetadataValue() { MetadataValue newMetadataValue = MetadataValue.builder().value("NEW").build(); - Task setCatalogItemMetadataValue = catalogClient.setCatalogItemMetadataValue(catalogItemRef, "KEY", newMetadataValue); + Task setCatalogItemMetadataValue = catalogClient.getMetadataClient().setMetadata(catalogItemRef, "KEY", newMetadataValue); checkTask(setCatalogItemMetadataValue); Checks.checkTask(setCatalogItemMetadataValue); assertTrue(retryTaskSuccess.apply(setCatalogItemMetadataValue), String.format(TASK_COMPLETE_TIMELY, "setCatalogItemMetadataValue")); - MetadataValue updatedMetadataValue = catalogClient.getCatalogItemMetadataValue(catalogItemRef, "KEY"); + MetadataValue updatedMetadataValue = catalogClient.getMetadataClient().getMetadataValue(catalogItemRef, "KEY"); assertEquals(updatedMetadataValue.getValue(), newMetadataValue.getValue(), String.format(CORRECT_VALUE_OBJECT_FMT, "Value", "MetadataValue", newMetadataValue.getValue(), updatedMetadataValue.getValue())); checkMetadataValue(updatedMetadataValue); @@ -238,13 +238,13 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(testName = "DELETE /catalog/{id}/metadata/{key}", dependsOnMethods = { "testSetCatalogItemMetadataValue" }) public void testDeleteCatalogItemMetadataValue() { - Task deleteCatalogItemMetadataValue = catalogClient.deleteCatalogItemMetadataValue(catalogItemRef, "KEY"); + Task deleteCatalogItemMetadataValue = catalogClient.getMetadataClient().deleteMetadataEntry(catalogItemRef, "KEY"); checkTask(deleteCatalogItemMetadataValue); Checks.checkTask(deleteCatalogItemMetadataValue); assertTrue(retryTaskSuccess.apply(deleteCatalogItemMetadataValue), String.format(TASK_COMPLETE_TIMELY, "deleteCatalogItemMetadataValue")); try { - catalogClient.getCatalogItemMetadataValue(catalogItemRef, "KEY"); + catalogClient.getMetadataClient().getMetadataValue(catalogItemRef, "KEY"); fail("The CatalogItem MetadataValue for KEY should have been deleted"); } catch (VCloudDirectorException vcde) { Error error = vcde.getError(); @@ -256,18 +256,18 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest { } private void deleteAllCatalogItemMetadata(ReferenceType catalogItemRef) { - Metadata currentMetadata = catalogClient.getCatalogItemMetadata(catalogItemRef); + Metadata currentMetadata = catalogClient.getMetadataClient().getMetadata(catalogItemRef); for (MetadataEntry currentMetadataEntry : currentMetadata.getMetadataEntries()) { - catalogClient.deleteCatalogItemMetadataValue(catalogItemRef, currentMetadataEntry.getKey()); + catalogClient.getMetadataClient().deleteMetadataEntry(catalogItemRef, currentMetadataEntry.getKey()); } - Metadata emptyMetadata = catalogClient.getCatalogItemMetadata(catalogItemRef); + Metadata emptyMetadata = catalogClient.getMetadataClient().getMetadata(catalogItemRef); assertTrue(emptyMetadata.getMetadataEntries().isEmpty(), "The catalogItem Metadata should be empty"); } private void resetCatalogItemMetadata(ReferenceType catalogItemRef) { deleteAllCatalogItemMetadata(catalogItemRef); Metadata newMetadata = Metadata.builder().entry(MetadataEntry.builder().entry("KEY", "VALUE").build()).build(); - Task mergeCatalogItemMetadata = catalogClient.mergeCatalogItemMetadata(catalogItemRef, newMetadata); + Task mergeCatalogItemMetadata = catalogClient.getMetadataClient().mergeMetadata(catalogItemRef, newMetadata); Checks.checkTask(mergeCatalogItemMetadata); assertTrue(retryTaskSuccess.apply(mergeCatalogItemMetadata), String.format(TASK_COMPLETE_TIMELY, "mergeCatalogItemMetadata")); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java index f5700e6fad..3a0be0a75d 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientExpectTest.java @@ -47,7 +47,7 @@ import org.testng.annotations.Test; * * @author danikov */ -@Test(groups = { "unit", "user", "media" }, singleThreaded = true, testName = "MediaClientExpectTest") +@Test(groups = { "unit", "media" }, singleThreaded = true, testName = "MediaClientExpectTest") public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTest { @Test @@ -280,7 +280,7 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes Metadata expected = metadata(); - assertEquals(client.getMediaClient().getMetadata(mediaRef), expected); + assertEquals(client.getMediaClient().getMetadataClient().getMetadata(mediaRef), expected); } @Test @@ -301,7 +301,7 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes Metadata inputMetadata = metadata(); Task expectedTask = mergeMetadataTask(); - assertEquals(client.getMediaClient().mergeMetadata(mediaRef, inputMetadata), expectedTask); + assertEquals(client.getMediaClient().getMetadataClient().mergeMetadata(mediaRef, inputMetadata), expectedTask); } public void testGetMetadataValue() { @@ -320,7 +320,7 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes Reference mediaRef = Reference.builder().href(mediaUri).build(); - assertEquals(client.getMediaClient().getMetadataValue(mediaRef, "key"), expected); + assertEquals(client.getMediaClient().getMetadataClient().getMetadataValue(mediaRef, "key"), expected); } @Test @@ -342,7 +342,7 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes Task expectedTask = setMetadataEntryTask(); - assertEquals(client.getMediaClient().setMetadata(mediaRef, "key", inputMetadataValue), expectedTask); + assertEquals(client.getMediaClient().getMetadataClient().setMetadata(mediaRef, "key", inputMetadataValue), expectedTask); } @Test @@ -361,7 +361,7 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes Reference mediaRef = Reference.builder().href(mediaUri).build(); Task expectedTask = deleteMetadataEntryTask(); - assertEquals(client.getMediaClient().deleteMetadataEntry(mediaRef, "key"), expectedTask); + assertEquals(client.getMediaClient().getMetadataClient().deleteMetadataEntry(mediaRef, "key"), expectedTask); } @Test diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java index e3a636b189..c807aa80c1 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaClientLiveTest.java @@ -175,7 +175,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { Checks.checkMediaFor(MEDIA, media); assertTrue(media.clone(oldMedia), ""); - mediaClient.setMetadata(media, "key", MetadataValue.builder().value("value").build()); + mediaClient.getMetadataClient().setMetadata(media, "key", MetadataValue.builder().value("value").build()); media = vdcClient.cloneMedia(vdcRef, CloneMediaParams.builder() .source(Reference.builder().fromEntity(media).build()) @@ -232,7 +232,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(testName = "GET /media/{id}/metadata", dependsOnMethods = { "testGetMedia" }, enabled = false) public void testGetMetadata() { - metadata = mediaClient.getMetadata(media); + metadata = mediaClient.getMetadataClient().getMetadata(media); // required for testing assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()), String.format(OBJ_FIELD_REQ_LIVE, MEDIA, "metadata.entries")); @@ -249,10 +249,10 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { .entries(inputEntries) .build(); - Task mergeMetadata = mediaClient.mergeMetadata(media, inputMetadata); + Task mergeMetadata = mediaClient.getMetadataClient().mergeMetadata(media, inputMetadata); Checks.checkTask(mergeMetadata); assertTrue(retryTaskSuccess.apply(mergeMetadata), String.format(TASK_COMPLETE_TIMELY, "mergeMetadata(new)")); - metadata = mediaClient.getMetadata(media); + metadata = mediaClient.getMetadataClient().getMetadata(media); Checks.checkMetadataFor(MEDIA, metadata); checkMetadataContainsEntries(metadata, inputEntries); @@ -265,10 +265,10 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { .entries(inputEntries) .build(); - mergeMetadata = mediaClient.mergeMetadata(media, inputMetadata); + mergeMetadata = mediaClient.getMetadataClient().mergeMetadata(media, inputMetadata); Checks.checkTask(mergeMetadata); assertTrue(retryTaskSuccess.apply(mergeMetadata), String.format(TASK_COMPLETE_TIMELY, "mergeMetadata(modify)")); - metadata = mediaClient.getMetadata(media); + metadata = mediaClient.getMetadataClient().getMetadata(media); Checks.checkMetadataFor(MEDIA, metadata); checkMetadataContainsEntries(metadata, inputEntries); @@ -296,7 +296,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(testName = "GET /media/{id}/metadata/{key}", dependsOnMethods = { "testMergeMetadata" }, enabled = false) public void testGetMetadataValue() { - metadataValue = mediaClient.getMetadataValue(media, "key"); + metadataValue = mediaClient.getMetadataClient().getMetadataValue(media, "key"); Checks.checkMetadataValueFor(MEDIA, metadataValue); } @@ -306,18 +306,18 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { metadataEntryValue = "newValue"; MetadataValue newValue = MetadataValue.builder().value(metadataEntryValue).build(); - Task setMetadataEntry = mediaClient.setMetadata(media, "key", newValue); + Task setMetadataEntry = mediaClient.getMetadataClient().setMetadata(media, "key", newValue); Checks.checkTask(setMetadataEntry); assertTrue(retryTaskSuccess.apply(setMetadataEntry), String.format(TASK_COMPLETE_TIMELY, "setMetadataEntry")); - metadataValue = mediaClient.getMetadataValue(media, "key"); + metadataValue = mediaClient.getMetadataClient().getMetadataValue(media, "key"); Checks.checkMetadataValueFor(MEDIA, metadataValue); } @Test(testName = "DELETE /media/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadataValue" }, enabled = false ) public void testDeleteMetadata() { - Task deleteMetadataEntry = mediaClient.deleteMetadataEntry(media, "testKey"); + Task deleteMetadataEntry = mediaClient.getMetadataClient().deleteMetadataEntry(media, "testKey"); Checks.checkTask(deleteMetadataEntry); assertTrue(retryTaskSuccess.apply(deleteMetadataEntry), String.format(TASK_COMPLETE_TIMELY, "deleteMetadataEntry")); @@ -329,7 +329,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { .build(); try { - metadataValue = mediaClient.getMetadataValue(media, "testKey"); + metadataValue = mediaClient.getMetadataClient().getMetadataValue(media, "testKey"); fail("Should give HTTP 403 error"); } catch (VCloudDirectorException vde) { assertEquals(vde.getError(), expected); @@ -344,7 +344,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest { "metadataEntry", metadataValue.toString())); } - metadataValue = mediaClient.getMetadataValue(media, "key"); + metadataValue = mediaClient.getMetadataClient().getMetadataValue(media, "key"); Checks.checkMetadataValueFor(MEDIA, metadataValue); media = mediaClient.getMedia(media); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java index f17857dc24..8f99fdd390 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientExpectTest.java @@ -164,7 +164,7 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT Reference networkRef = Reference.builder().href(networkUri).build(); - assertEquals(client.getNetworkClient().getMetadata(networkRef), expected); + assertEquals(client.getNetworkClient().getMetadataClient().getMetadata(networkRef), expected); } @Test(enabled=false) // No metadata in exemplar xml... @@ -181,7 +181,7 @@ public class NetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectT Reference networkRef = Reference.builder().href(networkUri).build(); - assertEquals(client.getNetworkClient().getMetadataValue(networkRef, "KEY"), expected); + assertEquals(client.getNetworkClient().getMetadataClient().getMetadataValue(networkRef, "KEY"), expected); } public static OrgNetwork orgNetwork() { diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java index 12a7259850..bbed422499 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkClientLiveTest.java @@ -100,7 +100,7 @@ public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(testName = "GET /network/{id}/metadata") public void testGetMetadata() { - Metadata metadata = networkClient.getMetadata(networkRef); + Metadata metadata = networkClient.getMetadataClient().getMetadata(networkRef); // required for testing assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()), String.format(OBJ_FIELD_REQ_LIVE, NETWORK, "metadata.entries")); @@ -122,7 +122,7 @@ public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(testName = "GET /network/{id}/metadata/{key}") public void testGetMetadataValue() { - MetadataValue metadataValue = networkClient.getMetadataValue(networkRef, "key"); + MetadataValue metadataValue = networkClient.getMetadataClient().getMetadataValue(networkRef, "key"); // Check parent type checkResourceType(metadataValue); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java index bb4773d53b..6489dacb3d 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientExpectTest.java @@ -195,7 +195,7 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest Reference orgRef = Reference.builder().href(orgUri).build(); - assertEquals(client.getOrgClient().getOrgMetadata(orgRef), expected); + assertEquals(client.getOrgClient().getMetadataClient().getMetadata(orgRef), expected); } @Test @@ -210,7 +210,7 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest Reference orgRef = Reference.builder().href(orgUri).build(); - assertEquals(client.getOrgClient().getOrgMetadataValue(orgRef, "KEY"), expected); + assertEquals(client.getOrgClient().getMetadataClient().getMetadataValue(orgRef, "KEY"), expected); } public static Org org() { diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java index e4ccf4c56c..bd03051da0 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java @@ -97,7 +97,7 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(testName = "GET /org/{id}/metadata/", dependsOnMethods = { "testGetOrg" }) public void testGetOrgMetadata() { // Call the method being tested - Metadata metadata = orgClient.getOrgMetadata(orgRef); + Metadata metadata = orgClient.getMetadataClient().getMetadata(orgRef); // NOTE The environment MUST have at one metadata entry for the first organisation configured @@ -110,7 +110,7 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(testName = "GET /org/{id}/metadata/{key}", dependsOnMethods = { "testGetOrgMetadata" }) public void testGetOrgMetadataValue() { // Call the method being tested - MetadataValue value = orgClient.getOrgMetadataValue(orgRef, "KEY"); + MetadataValue value = orgClient.getMetadataClient().getMetadataValue(orgRef, "KEY"); // NOTE The environment MUST have configured the metadata entry as '{ key="KEY", value="VALUE" )' diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java index bebbd34014..2fd8602681 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientExpectTest.java @@ -349,7 +349,7 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest Metadata expected = metadata(); - assertEquals(client.getMediaClient().getMetadata(mediaRef), expected); + assertEquals(client.getVdcClient().getMetadataClient().getMetadata(mediaRef), expected); } @Test(enabled = false) @@ -369,7 +369,7 @@ public class VdcClientExpectTest extends BaseVCloudDirectorRestClientExpectTest Reference mediaRef = Reference.builder().href(vdcUri).build(); - assertEquals(client.getVdcClient().getMetadataValue(mediaRef, "key"), expected); + assertEquals(client.getVdcClient().getMetadataClient().getMetadataValue(mediaRef, "key"), expected); } public static Vdc getVdc() { diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java index c7a67f29ca..a52922b44f 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcClientLiveTest.java @@ -243,7 +243,7 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(testName = "GET /network/{id}/metadata", enabled = false) public void testGetMetadata() { - Metadata metadata = vdcClient.getMetadata(vdcRef); + Metadata metadata = vdcClient.getMetadataClient().getMetadata(vdcRef); // required for testing assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()), String.format(OBJ_FIELD_REQ_LIVE, VDC, "metadata.entries")); @@ -253,7 +253,7 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest { @Test(testName = "GET /network/{id}/metadata/{key}", enabled = false) public void testGetMetadataValue() { - MetadataValue metadataValue = vdcClient.getMetadataValue(vdcRef, "key"); + MetadataValue metadataValue = vdcClient.getMetadataClient().getMetadataValue(vdcRef, "key"); Checks.checkMetadataValueFor(VDC, metadataValue); }