From 169006b3ed778faf7724d046237ca5e4e5436e23 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sun, 19 Aug 2012 18:48:58 -0700 Subject: [PATCH] Issue 830: refactored MediaClient to not require href arg; refactored VmApi, VAppApi, VAppTemplateApi to use urn --- labs/vcloud-director/pom.xml | 1 + .../director/v1_5/features/CatalogApi.java | 13 +- .../v1_5/features/CatalogAsyncApi.java | 11 +- .../director/v1_5/features/MediaApi.java | 8 +- .../director/v1_5/features/MediaAsyncApi.java | 7 +- .../director/v1_5/features/MetadataApi.java | 11 +- .../v1_5/features/MetadataAsyncApi.java | 25 +- .../director/v1_5/features/NetworkApi.java | 7 +- .../v1_5/features/NetworkAsyncApi.java | 5 +- .../vcloud/director/v1_5/features/OrgApi.java | 8 +- .../director/v1_5/features/OrgAsyncApi.java | 6 +- .../director/v1_5/features/VAppApi.java | 387 +++++++----- .../director/v1_5/features/VAppAsyncApi.java | 370 +++++++++-- .../v1_5/features/VAppTemplateApi.java | 244 ++++---- .../v1_5/features/VAppTemplateAsyncApi.java | 266 +++++--- .../vcloud/director/v1_5/features/VdcApi.java | 8 +- .../director/v1_5/features/VdcAsyncApi.java | 5 +- .../vcloud/director/v1_5/features/VmApi.java | 401 +++++++----- .../director/v1_5/features/VmAsyncApi.java | 583 ++++++++++++++++-- .../v1_5/features/admin/AdminCatalogApi.java | 9 +- .../features/admin/AdminCatalogAsyncApi.java | 6 +- .../v1_5/features/admin/AdminNetworkApi.java | 8 +- .../features/admin/AdminNetworkAsyncApi.java | 7 +- .../v1_5/features/admin/AdminOrgApi.java | 8 +- .../v1_5/features/admin/AdminOrgAsyncApi.java | 7 +- .../v1_5/features/admin/AdminVdcApi.java | 18 +- .../v1_5/features/admin/AdminVdcAsyncApi.java | 17 +- .../VAppTemplatesForCatalogItems.java | 2 +- .../v1_5/functions/href/MediaURNToHref.java | 43 ++ .../functions/href/VAppTemplateURNToHref.java | 43 ++ .../v1_5/functions/href/VAppURNToHref.java | 43 ++ .../v1_5/functions/href/VmURNToHref.java | 43 ++ .../v1_5/AbstractVAppApiLiveTest.java | 88 +-- .../v1_5/features/CatalogApiExpectTest.java | 14 +- .../v1_5/features/CatalogApiLiveTest.java | 36 +- .../v1_5/features/MediaApiExpectTest.java | 10 +- .../v1_5/features/MediaApiLiveTest.java | 242 ++++---- .../v1_5/features/NetworkApiExpectTest.java | 4 +- .../v1_5/features/NetworkApiLiveTest.java | 74 ++- .../v1_5/features/OrgApiExpectTest.java | 4 +- .../v1_5/features/OrgApiLiveTest.java | 23 +- .../v1_5/features/QueryApiLiveTest.java | 121 ++-- .../v1_5/features/VAppApiExpectTest.java | 14 +- .../v1_5/features/VAppApiLiveTest.java | 186 +++--- .../v1_5/features/VAppNetworksLiveTest.java | 27 +- .../features/VAppTemplateApiExpectTest.java | 138 +---- .../features/VAppTemplateApiLiveTest.java | 273 +++----- .../v1_5/features/VdcApiExpectTest.java | 4 +- .../v1_5/features/VdcApiLiveTest.java | 20 +- .../v1_5/features/VmApiExpectTest.java | 2 +- .../director/v1_5/features/VmApiLiveTest.java | 243 ++++---- .../features/admin/AdminVdcApiLiveTest.java | 20 +- .../BaseVCloudDirectorApiLiveTest.java | 312 ++++++---- 53 files changed, 2796 insertions(+), 1679 deletions(-) create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/href/MediaURNToHref.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/href/VAppTemplateURNToHref.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/href/VAppURNToHref.java create mode 100644 labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/href/VmURNToHref.java diff --git a/labs/vcloud-director/pom.xml b/labs/vcloud-director/pom.xml index 3d2a58046c..b007aad71b 100644 --- a/labs/vcloud-director/pom.xml +++ b/labs/vcloud-director/pom.xml @@ -43,6 +43,7 @@ + diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogApi.java index 0d59216064..08e9ff6f62 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogApi.java @@ -23,9 +23,12 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; +import org.jclouds.rest.annotations.EndpointParam; 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.functions.href.CatalogItemURNToHref; +import org.jclouds.vcloud.director.v1_5.functions.href.CatalogURNToHref; /** * Provides synchronous access to {@link Catalog} objects. @@ -118,12 +121,18 @@ public interface CatalogApi { * @return synchronous access to {@link Metadata.Readable} features */ @Delegate - MetadataApi.Readable getMetadataApi(); + MetadataApi.Readable getMetadataApi(@EndpointParam(parser = CatalogURNToHref.class) String catalogUrn); + + @Delegate + MetadataApi.Readable getMetadataApi(@EndpointParam URI catalogItemHref); /** * @return synchronous access to {@link Metadata.Writeable} features for CatalogItems */ @Delegate - MetadataApi.Writeable getItemMetadataApi(); + MetadataApi.Writeable getItemMetadataApi(@EndpointParam(parser = CatalogItemURNToHref.class) String catalogItemUrn); + + @Delegate + MetadataApi.Writeable getItemMetadataApi(@EndpointParam URI catalogItemHref); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogAsyncApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogAsyncApi.java index 98446585b1..6808341d71 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogAsyncApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/CatalogAsyncApi.java @@ -151,11 +151,18 @@ public interface CatalogAsyncApi { * @return asynchronous access to {@link Metadata.Readable} features */ @Delegate - MetadataAsyncApi.Readable getMetadataApi(); + MetadataAsyncApi.Readable getMetadataApi(@EndpointParam(parser = CatalogURNToHref.class) String catalogUrn); + + @Delegate + MetadataAsyncApi.Readable getMetadataApi(@EndpointParam URI catalogItemHref); /** * @see CatalogApi#getItemMetadataApi */ @Delegate - MetadataAsyncApi.Writeable getItemMetadataApi(); + MetadataAsyncApi.Writeable getItemMetadataApi(@EndpointParam(parser = CatalogItemURNToHref.class) String catalogItemUrn); + + @Delegate + MetadataAsyncApi.Writeable getItemMetadataApi(@EndpointParam URI catalogItemHref); + } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaApi.java index b2d9bd8604..45dbe18086 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaApi.java @@ -23,10 +23,13 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; +import org.jclouds.rest.annotations.EndpointParam; 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.Owner; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.params.CloneMediaParams; +import org.jclouds.vcloud.director.v1_5.functions.href.MediaURNToHref; /** * Provides synchronous access to {@link Media}. @@ -84,6 +87,9 @@ public interface MediaApi { * @return synchronous access to {@link Metadata.Writeable} features */ @Delegate - MetadataApi.Writeable getMetadataApi(); + MetadataApi.Writeable getMetadataApi(@EndpointParam(parser = MediaURNToHref.class) String mediaUrn); + + @Delegate + MetadataApi.Writeable getMetadataApi(@EndpointParam URI mediaUri); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaAsyncApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaAsyncApi.java index c0b6c0bf1d..0932186cc3 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaAsyncApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MediaAsyncApi.java @@ -38,10 +38,12 @@ import org.jclouds.rest.binders.BindToXMLPayload; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; 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.Owner; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.params.CloneMediaParams; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationAndCookieToRequest; +import org.jclouds.vcloud.director.v1_5.functions.href.MediaURNToHref; import com.google.common.util.concurrent.ListenableFuture; @@ -114,5 +116,8 @@ public interface MediaAsyncApi { * @return asynchronous access to {@link Metadata.Writeable} features */ @Delegate - MetadataAsyncApi.Writeable getMetadataApi(); + MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam(parser = MediaURNToHref.class) String mediaUrn); + + @Delegate + MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam URI uri); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataApi.java index c301e6004f..18db889110 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataApi.java @@ -18,7 +18,6 @@ */ package org.jclouds.vcloud.director.v1_5.features; -import java.net.URI; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; @@ -41,14 +40,14 @@ public interface MetadataApi { * * @return a list of metadata */ - Metadata get(URI uri); + Metadata get(); /** * Retrieves a metadata value * * @return the metadata value, or null if not found */ - MetadataValue getValue(URI uri, String key); + MetadataValue getValue(String key); } @Timeout(duration = 180, timeUnit = TimeUnit.SECONDS) @@ -60,7 +59,7 @@ public interface MetadataApi { * @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 merge(URI uri, Metadata metadata); + Task merge(Metadata metadata); /** * Sets the metadata for the particular key for the media to the value provided. Note: this @@ -69,7 +68,7 @@ public interface MetadataApi { * @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 putEntry(URI uri, String key, MetadataValue metadataValue); + Task putEntry(String key, MetadataValue metadataValue); /** * Deletes a metadata entry. @@ -77,7 +76,7 @@ public interface MetadataApi { * @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 removeEntry(URI uri, String key); + Task removeEntry(String key); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataAsyncApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataAsyncApi.java index f63858563f..dcb9b1bb56 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataAsyncApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/MetadataAsyncApi.java @@ -30,7 +30,6 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.RequestFilters; @@ -38,6 +37,7 @@ import org.jclouds.rest.binders.BindToXMLPayload; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; 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.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationAndCookieToRequest; @@ -48,7 +48,7 @@ import com.google.common.util.concurrent.ListenableFuture; * @see MetadataApi * @author danikov */ -//TODO: take out the endpoint params and supply them in the Delegate calls. +// TODO: take out the endpoint params and supply them in the Delegate calls. public interface MetadataAsyncApi { @RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class) @@ -62,17 +62,17 @@ public interface MetadataAsyncApi { @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture get(@EndpointParam URI metaDataUri); + ListenableFuture get(); /** - * @see MetadataApi.Readable#getValue(URI, String) + * @see MetadataApi.Readable#getValue(String) */ @GET @Path("/metadata/{key}") @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getValue(@EndpointParam URI metaDataUri, @PathParam("key") String key); + ListenableFuture getValue(@PathParam("key") String key); } @@ -80,18 +80,17 @@ public interface MetadataAsyncApi { public static interface Writeable extends Readable { /** - * @see MetadataApi.Writable#merge(URI, Metadata)) + * @see MetadataApi.Writable#merge(Metadata) */ @POST @Path("/metadata") @Consumes(VCloudDirectorMediaType.TASK) @Produces(VCloudDirectorMediaType.METADATA) @JAXBResponseParser - ListenableFuture merge(@EndpointParam URI metaDataUri, - @BinderParam(BindToXMLPayload.class) Metadata metadata); + ListenableFuture merge(@BinderParam(BindToXMLPayload.class) Metadata metadata); /** - * @see MetadataApi.Writeable#putEntry(URI, String, MetadataEntry)) + * @see MetadataApi.Writeable#putEntry(String, MetadataEntry) */ @PUT @Path("/metadata/{key}") @@ -99,17 +98,17 @@ public interface MetadataAsyncApi { @Produces(VCloudDirectorMediaType.METADATA_VALUE) @JAXBResponseParser // TODO: this is rediculous. get rid of the MetadataValue type, as it is only a string! - ListenableFuture putEntry(@EndpointParam URI metaDataUri, @PathParam("key") String key, + ListenableFuture putEntry(@PathParam("key") String key, @BinderParam(BindToXMLPayload.class) MetadataValue metadataValue); - + /** - * @see MetadataApi.Writable#removeEntry(URI, String)) + * @see MetadataApi.Writable#removeEntry(String) */ @DELETE @Path("/metadata/{key}") @Consumes(VCloudDirectorMediaType.TASK) @JAXBResponseParser - ListenableFuture removeEntry(@EndpointParam URI metaDataUri, @PathParam("key") String key); + ListenableFuture removeEntry(@PathParam("key") String key); } } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkApi.java index f64065d36b..1de6875666 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkApi.java @@ -23,8 +23,10 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; +import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.network.Network; +import org.jclouds.vcloud.director.v1_5.functions.href.NetworkURNToHref; /** * Provides synchronous access to {@link Network}. @@ -48,5 +50,8 @@ public interface NetworkApi { * @return synchronous access to {@link Metadata.Readable} features */ @Delegate - MetadataApi.Readable getMetadataApi(); + MetadataApi.Readable getMetadataApi(@EndpointParam(parser = NetworkURNToHref.class) String networkUrn); + + @Delegate + MetadataApi.Readable getMetadataApi(@EndpointParam URI networkHref); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkAsyncApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkAsyncApi.java index 697ee8cb54..febe0f8652 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkAsyncApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/NetworkAsyncApi.java @@ -65,6 +65,9 @@ public interface NetworkAsyncApi { * @return asynchronous access to {@link Metadata.Readable} features */ @Delegate - MetadataAsyncApi.Readable getMetadataApi(); + MetadataAsyncApi.Readable getMetadataApi(@EndpointParam(parser = NetworkURNToHref.class) String networkUrn); + + @Delegate + MetadataAsyncApi.Readable getMetadataApi(@EndpointParam URI networkHref); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgApi.java index b9f35a6b47..b73674e1b7 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgApi.java @@ -23,9 +23,11 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; +import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.org.Org; import org.jclouds.vcloud.director.v1_5.domain.org.OrgList; +import org.jclouds.vcloud.director.v1_5.functions.href.OrgURNToHref; /** * Provides synchronous access to {@link Org}. @@ -64,5 +66,9 @@ public interface OrgApi { * @return synchronous access to {@link Metadata.Readable} features */ @Delegate - MetadataApi.Readable getMetadataApi(); + MetadataApi.Readable getMetadataApi(@EndpointParam(parser = OrgURNToHref.class) String orgUrn); + + @Delegate + MetadataApi.Readable getMetadataApi(@EndpointParam URI orgHref); + } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncApi.java index 121ea8c6ea..7b2ef31cf2 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncApi.java @@ -76,5 +76,9 @@ public interface OrgAsyncApi { * @return asynchronous access to {@link Metadata.Readable} features */ @Delegate - MetadataAsyncApi.Readable getMetadataApi(); + MetadataAsyncApi.Readable getMetadataApi(@EndpointParam(parser = OrgURNToHref.class) String orgUrn); + + @Delegate + MetadataAsyncApi.Readable getMetadataApi(@EndpointParam URI orgHref); + } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppApi.java index 542ccd70ac..00bb708105 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppApi.java @@ -25,6 +25,7 @@ import org.jclouds.concurrent.Timeout; import org.jclouds.dmtf.ovf.NetworkSection; import org.jclouds.dmtf.ovf.StartupSection; import org.jclouds.rest.annotations.Delegate; +import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList; @@ -36,11 +37,12 @@ import org.jclouds.vcloud.director.v1_5.domain.params.RecomposeVAppParams; import org.jclouds.vcloud.director.v1_5.domain.params.UndeployVAppParams; import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection; import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; +import org.jclouds.vcloud.director.v1_5.functions.href.VAppURNToHref; /** * Provides synchronous access to {@link VApp} objects. - * - * @author grkvlt@apache.org + * + * @author grkvlt@apache.org, Adrian Cole * @see VAppAsyncApi * @version 1.5 */ @@ -49,391 +51,456 @@ public interface VAppApi { /** * Retrieves a {@link VApp}. - * + * * The {@link VApp} could be in one of these statuses: *
    - *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#FAILED_CREATION FAILED_CREATION(-1)} - - * Transient entity state, e.g., model object is addd but the corresponding VC backing does not - * exist yet. This is further sub-categorized in the respective entities. - *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNRESOLVED UNRESOLVED(0)} - - * Entity is whole, e.g., VM creation is complete and all the required model objects and VC backings are - * created. - *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#RESOLVED RESOLVED(1)} - - * Entity is resolved. - *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#DEPLOYED DEPLOYED(2)} - - * Entity is deployed. - *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#SUSPENDED SUSPENDED(3)} - - * All VMs of the vApp are suspended. - *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#POWERED_ON POWERED_ON(4)} - - * All VMs of the vApp are powered on. - *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#WAITING_FOR_INPUT WAITING_FOR_INPUT(5)} - - * VM is pending response on a question. - *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNKNOWN UNKNOWN(6)} - - * Entity state could not be retrieved from the inventory, e.g., VM power state is null. - *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNRECOGNIZED UNRECOGNIZED(7)} - - * Entity state was retrieved from the inventory but could not be mapped to an internal state. - *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#POWERED_OFF POWERED_OFF(8)} - - * All VMs of the vApp are powered off. - *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#INCONSISTENT_STATE INCONSISTENT_STATE(9)} - - * Apply to VM status, if a vm is {@code POWERED_ON}, or {@code WAITING_FOR_INPUT}, but is - * undeployed, it is in an inconsistent state. - *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#MIXED MIXED(10)} - - * vApp status is set to {@code MIXED} when the VMs in the vApp are in different power states + *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#FAILED_CREATION + * FAILED_CREATION(-1)} - Transient entity state, e.g., model object is addd but the + * corresponding VC backing does not exist yet. This is further sub-categorized in the respective + * entities. + *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNRESOLVED + * UNRESOLVED(0)} - Entity is whole, e.g., VM creation is complete and all the required model + * objects and VC backings are created. + *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#RESOLVED + * RESOLVED(1)} - Entity is resolved. + *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#DEPLOYED + * DEPLOYED(2)} - Entity is deployed. + *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#SUSPENDED + * SUSPENDED(3)} - All VMs of the vApp are suspended. + *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#POWERED_ON + * POWERED_ON(4)} - All VMs of the vApp are powered on. + *
  • + * {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#WAITING_FOR_INPUT + * WAITING_FOR_INPUT(5)} - VM is pending response on a question. + *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNKNOWN + * UNKNOWN(6)} - Entity state could not be retrieved from the inventory, e.g., VM power state is + * null. + *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNRECOGNIZED + * UNRECOGNIZED(7)} - Entity state was retrieved from the inventory but could not be mapped to an + * internal state. + *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#POWERED_OFF + * POWERED_OFF(8)} - All VMs of the vApp are powered off. + *
  • + * {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#INCONSISTENT_STATE + * INCONSISTENT_STATE(9)} - Apply to VM status, if a vm is {@code POWERED_ON}, or + * {@code WAITING_FOR_INPUT}, but is undeployed, it is in an inconsistent state. + *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#MIXED MIXED(10)} + * - vApp status is set to {@code MIXED} when the VMs in the vApp are in different power states *
- * + * *
     * GET /vApp/{id}
     * 
- * + * * @since 0.9 */ - VApp getVApp(URI vAppURI); + VApp get(String vAppUrn); + + VApp get(URI vAppHref); /** * Modifies the name/description of a {@link VApp}. - * + * *
     * PUT /vApp/{id}
     * 
- * + * * @since 0.9 */ - Task editVApp(URI vAppURI, VApp vApp); + Task edit(String vAppUrn, VApp vApp); + + Task edit(URI vAppHref, VApp vApp); /** * Deletes a {@link VApp}. - * + * *
     * DELETE /vApp/{id}
     * 
- * + * * @since 0.9 */ - Task removeVApp(URI vAppURI); + Task remove(String vAppUrn); + + Task remove(URI vAppHref); /** * Modifies the control access of a {@link VApp}. - * + * *
     * POST /vApp/{id}/action/controlAccess
     * 
- * + * * @since 0.9 */ - ControlAccessParams editControlAccess(URI vAppURI, ControlAccessParams params); + ControlAccessParams editControlAccess(String vAppUrn, ControlAccessParams params); + + ControlAccessParams editControlAccess(URI vAppHref, ControlAccessParams params); /** * Deploys a {@link VApp}. - * - * Deployment means allocation of all resource for a vApp/VM like CPU and memory - * from a vDC resource pool. Deploying a vApp automatically deploys all of the - * virtual machines it contains. As of version 1.5 the operation supports force - * customization passed with {@link DeployVAppParamsType#setForceCustomization(Boolean)} - * parameter. - * + * + * Deployment means allocation of all resource for a vApp/VM like CPU and memory from a vDC + * resource pool. Deploying a vApp automatically deploys all of the virtual machines it contains. + * As of version 1.5 the operation supports force customization passed with + * {@link DeployVAppParamsType#setForceCustomization(Boolean)} parameter. + * *
     * POST /vApp/{id}/action/deploy
     * 
- * + * * @since 0.9 */ - Task deploy(URI vAppURI, DeployVAppParams params); + Task deploy(String vAppUrn, DeployVAppParams params); + + Task deploy(URI vAppHref, DeployVAppParams params); /** * Discard suspended state of a {@link VApp}. - * - * Discarding suspended state of a vApp automatically discarded suspended - * states of all of the virtual machines it contains. - * + * + * Discarding suspended state of a vApp automatically discarded suspended states of all of the + * virtual machines it contains. + * *
     * POST /vApp/{id}/action/discardSuspendedState
     * 
- * + * * @since 0.9 */ - Task discardSuspendedState(URI vAppURI); + Task discardSuspendedState(String vAppUrn); + + Task discardSuspendedState(URI vAppHref); /** * Place the {@link VApp} into maintenance mode. - * - * While in maintenance mode, a system admin can operate on the vApp as - * usual, but end users are restricted to read-only operations. Any - * user-initiated tasks running when the vApp enters maintenance mode will - * continue. - * + * + * While in maintenance mode, a system admin can operate on the vApp as usual, but end users are + * restricted to read-only operations. Any user-initiated tasks running when the vApp enters + * maintenance mode will continue. + * *
     * POST /vApp/{id}/action/enterMaintenanceMode
     * 
- * + * * @since 1.5 */ - void enterMaintenanceMode(URI vAppURI); + void enterMaintenanceMode(String vAppUrn); + + void enterMaintenanceMode(URI vAppHref); /** * Take the {@link VApp} out of maintenance mode. - * + * *
     * POST /vApp/{id}/action/exitMaintenanceMode
     * 
- * + * * @since 1.5 */ - void exitMaintenanceMode(URI vAppURI); + void exitMaintenanceMode(String vAppUrn); + + void exitMaintenanceMode(URI vAppHref); /** - * Recompose a {@link VApp} by removing its own VMs and/or adding new ones from other - * vApps or vApp templates. - * - * To remove VMs you should put their references in elements. The way you add - * VMs is the same as described in compose vApp operation - * {@link VdcApi#composeVApp(URI, org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams)}. - * The status of vApp will be in {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNRESOLVED} - * until the recompose task is finished. - * + * Recompose a {@link VApp} by removing its own VMs and/or adding new ones from other vApps or + * vApp templates. + * + * To remove VMs you should put their references in elements. The way you add VMs is the same as + * described in compose vApp operation + * {@link VdcApi#composeVApp(String, org.jclouds.vcloud.director.v1_5.domain.ComposeVAppParams)}. + * The status of vApp will be in + * {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNRESOLVED} until the + * recompose task is finished. + * *
     * POST /vApp/{id}/action/recomposeVApp
     * 
- * + * * @since 1.0 */ - Task recompose(URI vAppURI, RecomposeVAppParams params); + Task recompose(String vAppUrn, RecomposeVAppParams params); + + Task recompose(URI vAppHref, RecomposeVAppParams params); /** * Undeploy a {@link VApp}. - * - * Undeployment means deallocation of all resources for a vApp/VM like CPU - * and memory from a vDC resource pool. Undeploying a vApp automatically - * undeploys all of the virtual machines it contains. - * + * + * Undeployment means deallocation of all resources for a vApp/VM like CPU and memory from a vDC + * resource pool. Undeploying a vApp automatically undeploys all of the virtual machines it + * contains. + * *
     * POST /vApp/{id}/action/undeploy
     * 
- * + * * @since 0.9 */ - Task undeploy(URI vAppURI, UndeployVAppParams params); + Task undeploy(String vAppUrn, UndeployVAppParams params); + + Task undeploy(URI vAppHref, UndeployVAppParams params); /** * Retrieves the control access information for a {@link VApp}. - * - * The vApp could be shared to everyone or could be shared to specific user, - * by editing the control access values. - * + * + * The vApp could be shared to everyone or could be shared to specific user, by editing the + * control access values. + * *
     * GET /vApp/{id}/controlAccess
     * 
- * + * * @since 0.9 */ - //TODO: revise - ControlAccessParams getControlAccess(URI vAppURI); + // TODO: revise + ControlAccessParams getAccessControl(String vAppUrn); + + ControlAccessParams getAccessControl(URI vAppHref); /** * Powers off a {@link VApp}. - * - * If the operation is used over a vApp then all VMs are powered off. This operation is allowed only when the vApp/VM is powered on. - * + * + * If the operation is used over a vApp then all VMs are powered off. This operation is allowed + * only when the vApp/VM is powered on. + * *
     * POST /vApp/{id}/power/action/powerOff
     * 
- * + * * @since 0.9 */ - Task powerOff(URI vAppURI); + Task powerOff(String vAppUrn); + + Task powerOff(URI vAppHref); /** * Powers on a {@link VApp}. - * - * If the operation is used over a vApp then all VMs are powered on. This - * operation is allowed only when the vApp/VM is powered off. - * + * + * If the operation is used over a vApp then all VMs are powered on. This operation is allowed + * only when the vApp/VM is powered off. + * *
     * POST /vApp/{id}/power/action/powerOn
     * 
- * + * * @since 0.9 */ - Task powerOn(URI vAppURI); + Task powerOn(String vAppUrn); + + Task powerOn(URI vAppHref); /** * Reboots a {@link VApp}. - * + * * The vApp/VM should be started in order to reboot it. - * + * *
     * POST /vApp/{id}/power/action/reboot
     * 
- * + * * @since 0.9 */ - Task reboot(URI vAppURI); + Task reboot(String vAppUrn); + + Task reboot(URI vAppHref); /** * Resets a {@link VApp}. - * - * If the operation is used over a vApp then all VMs are reset. This - * operation is allowed only when the vApp/VM is powered on. - * + * + * If the operation is used over a vApp then all VMs are reset. This operation is allowed only + * when the vApp/VM is powered on. + * *
     * POST /vApp/{id}/power/action/reset
     * 
- * + * * @since 0.9 */ - Task reset(URI vAppURI); + Task reset(String vAppUrn); + + Task reset(URI vAppHref); /** * Shuts down a {@link VApp}. - * - * If the operation is used over a vApp then all VMs are shutdown. This - * operation is allowed only when the vApp/VM is powered on. - * + * + * If the operation is used over a vApp then all VMs are shutdown. This operation is allowed only + * when the vApp/VM is powered on. + * *
     * POST /vApp/{id}/power/action/shutdown
     * 
- * + * * @since 0.9 */ - Task shutdown(URI vAppURI); + Task shutdown(String vAppUrn); + + Task shutdown(URI vAppHref); /** * Suspends a {@link VApp}. - * - * If the operation is used over a vApp then all VMs are suspended. This - * operation is allowed only when the vApp/VM is powered on. - * + * + * If the operation is used over a vApp then all VMs are suspended. This operation is allowed + * only when the vApp/VM is powered on. + * *
     * POST /vApp/{id}/power/action/suspend
     * 
- * + * * @since 0.9 */ - Task suspend(URI vAppURI); + Task suspend(String vAppUrn); + + Task suspend(URI vAppHref); /** * Retrieves the lease settings section of a {@link VApp}. - * + * *
     * GET /vApp/{id}/leaseSettingsSection
     * 
- * + * * @since 0.9 */ - LeaseSettingsSection getLeaseSettingsSection(URI vAppURI); + LeaseSettingsSection getLeaseSettingsSection(String vAppUrn); + + LeaseSettingsSection getLeaseSettingsSection(URI vAppHref); /** * Modifies the lease settings section of a {@link VApp}. - * + * *
     * PUT /vApp/{id}/leaseSettingsSection
     * 
- * + * * @since 0.9 */ - Task editLeaseSettingsSection(URI vAppURI, LeaseSettingsSection section); + Task editLeaseSettingsSection(String vAppUrn, LeaseSettingsSection section); + + Task editLeaseSettingsSection(URI vAppHref, LeaseSettingsSection section); /** * Retrieves the network config section of a {@link VApp}. - * + * *
     * GET /vApp/{id}/networkConfigSection
     * 
- * + * * @since 0.9 */ - NetworkConfigSection getNetworkConfigSection(URI vAppURI); + NetworkConfigSection getNetworkConfigSection(String vAppUrn); + + NetworkConfigSection getNetworkConfigSection(URI vAppHref); /** * Modifies the network config section of a {@link VApp}. - * + * *
     * PUT /vApp/{id}/networkConfigSection
     * 
- * + * * @since 0.9 */ - Task editNetworkConfigSection(URI vAppURI, NetworkConfigSection section); + Task editNetworkConfigSection(String vAppUrn, NetworkConfigSection section); + + Task editNetworkConfigSection(URI vAppHref, NetworkConfigSection section); /** * Retrieves the network section of a {@link VApp}. - * + * *
     * GET /vApp/{id}/networkSection
     * 
- * + * * @since 0.9 */ - NetworkSection getNetworkSection(URI vAppURI); + NetworkSection getNetworkSection(String vAppUrn); + + NetworkSection getNetworkSection(URI vAppHref); /** * Retrieves the owner of a {@link VApp}. - * + * *
     * GET /vApp/{id}/owner
     * 
- * + * * @since 1.5 */ - Owner getOwner(URI vAppURI); + Owner getOwner(String vAppUrn); + + Owner getOwner(URI vAppHref); /** * Changes {@link VApp} owner. - * + * *
     * PUT /vApp/{id}/owner
     * 
- * + * * @since 1.5 */ - void editOwner(URI vAppURI, Owner owner); + void editOwner(String vAppUrn, Owner owner); + + void editOwner(URI vAppHref, Owner owner); /** * Retrieves {@link VApp} product sections. - * + * *
     * GET /vApp/{id}/productSections
     * 
- * + * * @since 1.5 */ - ProductSectionList getProductSections(URI vAppURI); + ProductSectionList getProductSections(String vAppUrn); + + ProductSectionList getProductSections(URI vAppHref); /** * Modifies the product section information of a {@link VApp}. - * + * *
     * PUT /vApp/{id}/productSections
     * 
- * + * * @since 1.5 */ - Task editProductSections(URI vAppURI, ProductSectionList sectionList); + Task editProductSections(String vAppUrn, ProductSectionList sectionList); + + Task editProductSections(URI vAppHref, ProductSectionList sectionList); /** * Retrieves the startup section of a {@link VApp}. - * + * *
     * GET /vApp/{id}/startupSection
     * 
- * + * * @since 0.9 */ - StartupSection getStartupSection(URI vAppURI); + StartupSection getStartupSection(String vAppUrn); + + StartupSection getStartupSection(URI vAppHref); /** * Modifies the startup section of a {@link VApp}. - * + * *
     * PUT /vApp/{id}/startupSection
     * 
- * + * * @since 0.9 */ - Task editStartupSection(URI vAppURI, StartupSection section); + Task editStartupSection(String vAppUrn, StartupSection section); + + Task editStartupSection(URI vAppHref, StartupSection section); /** * Synchronous access to {@link VApp} {@link Metadata} features. */ @Delegate - MetadataApi.Writeable getMetadataApi(); + MetadataApi.Writeable getMetadataApi(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn); + + @Delegate + MetadataApi.Writeable getMetadataApi(@EndpointParam URI vAppHref); + } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppAsyncApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppAsyncApi.java index fce2a2e27d..a62bc841ff 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppAsyncApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppAsyncApi.java @@ -50,6 +50,7 @@ import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.binders.BindToXMLPayload; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList; import org.jclouds.vcloud.director.v1_5.domain.Task; @@ -61,6 +62,7 @@ import org.jclouds.vcloud.director.v1_5.domain.params.UndeployVAppParams; import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection; import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationAndCookieToRequest; +import org.jclouds.vcloud.director.v1_5.functions.href.VAppURNToHref; import com.google.common.util.concurrent.ListenableFuture; @@ -72,31 +74,309 @@ import com.google.common.util.concurrent.ListenableFuture; public interface VAppAsyncApi { /** - * @see VAppApi#getVApp(URI) + * @see VAppApi#get(String) */ @GET @Consumes(VAPP) @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getVApp(@EndpointParam URI vAppURI); + ListenableFuture get(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn); /** - * @see VAppApi#editVApp(URI, VApp) + * @see VAppApi#edit(String, VApp) */ @PUT @Produces(VAPP) @Consumes(TASK) @JAXBResponseParser - ListenableFuture editVApp(@EndpointParam URI vAppURI, - @BinderParam(BindToXMLPayload.class) VApp vApp); + ListenableFuture edit(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn, + @BinderParam(BindToXMLPayload.class) VApp vApp); /** - * @see VAppApi#removeVApp(URI) + * @see VAppApi#remove(String) */ @DELETE @Consumes(TASK) @JAXBResponseParser - ListenableFuture removeVApp(@EndpointParam URI vAppURI); + ListenableFuture remove(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn); + + /** + * @see VAppApi#editControlAccess(String, ControlAccessParams) + */ + @POST + @Path("/action/controlAccess") + @Produces(CONTROL_ACCESS) + @Consumes(CONTROL_ACCESS) + @JAXBResponseParser + ListenableFuture editControlAccess(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn, + @BinderParam(BindToXMLPayload.class) ControlAccessParams params); + + /** + * @see VAppApi#deploy(String, DeployVAppParams) + */ + @POST + @Path("/action/deploy") + @Produces(DEPLOY_VAPP_PARAMS) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture deploy(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn, + @BinderParam(BindToXMLPayload.class) DeployVAppParams params); + + /** + * @see VAppApi#discardSuspendedState(String) + */ + @POST + @Path("/action/discardSuspendedState") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture discardSuspendedState(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn); + + /** + * @see VAppApi#enterMaintenanceMode(String) + */ + @POST + @Path("/action/enterMaintenanceMode") + @Consumes + @JAXBResponseParser + ListenableFuture enterMaintenanceMode(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn); + + /** + * @see VAppApi#exitMaintenanceMode(String) + */ + @POST + @Path("/action/exitMaintenanceMode") + @Consumes + @JAXBResponseParser + ListenableFuture exitMaintenanceMode(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn); + + /** + * @see VAppApi#recompose(String, RecomposeVAppParams) + */ + @POST + @Path("/action/recomposeVApp") + @Produces(RECOMPOSE_VAPP_PARAMS) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture recompose(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn, + @BinderParam(BindToXMLPayload.class) RecomposeVAppParams params); + + /** + * @see VAppApi#undeploy(String, UndeployVAppParams) + */ + @POST + @Path("/action/undeploy") + @Produces(UNDEPLOY_VAPP_PARAMS) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture undeploy(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn, + @BinderParam(BindToXMLPayload.class) UndeployVAppParams params); + + /** + * @see VAppApi#getAccessControl(String) + */ + @GET + @Path("/controlAccess") + @Consumes(CONTROL_ACCESS) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getAccessControl(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn); + + /** + * @see VAppApi#powerOff(String) + */ + @POST + @Path("/power/action/powerOff") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture powerOff(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn); + + /** + * @see VAppApi#powerOn(String) + */ + @POST + @Path("/power/action/powerOn") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture powerOn(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn); + + /** + * @see VAppApi#reboot(String) + */ + @POST + @Path("/power/action/powerOff") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture reboot(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn); + + /** + * @see VAppApi#reset(String) + */ + @POST + @Path("/power/action/reset") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture reset(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn); + + /** + * @see VAppApi#shutdown(String) + */ + @POST + @Path("/power/action/shutdown") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture shutdown(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn); + + /** + * @see VAppApi#suspend(String) + */ + @POST + @Path("/power/action/suspend") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture suspend(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn); + + /** + * @see VAppApi#getLeaseSettingsSection(String) + */ + @GET + @Path("/leaseSettingsSection") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getLeaseSettingsSection( + @EndpointParam(parser = VAppURNToHref.class) String vAppUrn); + + /** + * @see VAppApi#editLeaseSettingsSection(String, LeaseSettingsSection) + */ + @PUT + @Path("/leaseSettingsSection") + @Produces(LEASE_SETTINGS_SECTION) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture editLeaseSettingsSection(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn, + @BinderParam(BindToXMLPayload.class) LeaseSettingsSection section); + + /** + * @see VAppApi#getNetworkConfigSection(String) + */ + @GET + @Path("/networkConfigSection") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getNetworkConfigSection( + @EndpointParam(parser = VAppURNToHref.class) String vAppUrn); + + /** + * @see VAppApi#editNetworkConfigSection(String, NetworkConfigSection) + */ + @PUT + @Path("/networkConfigSection") + @Produces(NETWORK_CONFIG_SECTION) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture editNetworkConfigSection(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn, + @BinderParam(BindToXMLPayload.class) NetworkConfigSection section); + + /** + * @see VAppApi#getNetworkSection(String) + */ + @GET + @Path("/networkSection") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getNetworkSection(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn); + + /** + * @see VAppApi#getOwner(String) + */ + @GET + @Path("/owner") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getOwner(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn); + + /** + * @see VAppApi#editOwner(String, Owner) + */ + @PUT + @Path("/owner") + @Produces(OWNER) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture editOwner(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn, + @BinderParam(BindToXMLPayload.class) Owner owner); + + /** + * @see VAppApi#getProductSections(String) + */ + @GET + @Path("/productSections") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getProductSections(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn); + + /** + * @see VAppApi#editProductSections(String, ProductSectionList) + */ + @PUT + @Path("/productSections") + @Produces(PRODUCT_SECTION_LIST) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture editProductSections(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn, + @BinderParam(BindToXMLPayload.class) ProductSectionList sectionList); + + /** + * @see VAppApi#getStartupSection(String) + */ + @GET + @Path("/startupSection") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getStartupSection(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn); + + /** + * @see VAppApi#editStartupSection(String, StartupSection) + */ + @PUT + @Path("/startupSection") + @Produces(STARTUP_SECTION) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture editStartupSection(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn, + @BinderParam(BindToXMLPayload.class) StartupSection section); + + /** + * @see VAppApi#get(URI) + */ + @GET + @Consumes(VAPP) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture get(@EndpointParam URI vAppHref); + + /** + * @see VAppApi#edit(URI, VApp) + */ + @PUT + @Produces(VAPP) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture edit(@EndpointParam URI vAppHref, @BinderParam(BindToXMLPayload.class) VApp vApp); + + /** + * @see VAppApi#remove(URI) + */ + @DELETE + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture remove(@EndpointParam URI vAppHref); /** * @see VAppApi#editControlAccess(URI, ControlAccessParams) @@ -106,8 +386,8 @@ public interface VAppAsyncApi { @Produces(CONTROL_ACCESS) @Consumes(CONTROL_ACCESS) @JAXBResponseParser - ListenableFuture editControlAccess(@EndpointParam URI vAppURI, - @BinderParam(BindToXMLPayload.class) ControlAccessParams params); + ListenableFuture editControlAccess(@EndpointParam URI vAppHref, + @BinderParam(BindToXMLPayload.class) ControlAccessParams params); /** * @see VAppApi#deploy(URI, DeployVAppParams) @@ -117,8 +397,8 @@ public interface VAppAsyncApi { @Produces(DEPLOY_VAPP_PARAMS) @Consumes(TASK) @JAXBResponseParser - ListenableFuture deploy(@EndpointParam URI vAppURI, - @BinderParam(BindToXMLPayload.class) DeployVAppParams params); + ListenableFuture deploy(@EndpointParam URI vAppHref, + @BinderParam(BindToXMLPayload.class) DeployVAppParams params); /** * @see VAppApi#discardSuspendedState(URI) @@ -127,7 +407,7 @@ public interface VAppAsyncApi { @Path("/action/discardSuspendedState") @Consumes(TASK) @JAXBResponseParser - ListenableFuture discardSuspendedState(@EndpointParam URI vAppURI); + ListenableFuture discardSuspendedState(@EndpointParam URI vAppHref); /** * @see VAppApi#enterMaintenanceMode(URI) @@ -136,7 +416,7 @@ public interface VAppAsyncApi { @Path("/action/enterMaintenanceMode") @Consumes @JAXBResponseParser - ListenableFuture enterMaintenanceMode(@EndpointParam URI vAppURI); + ListenableFuture enterMaintenanceMode(@EndpointParam URI vAppHref); /** * @see VAppApi#exitMaintenanceMode(URI) @@ -145,7 +425,7 @@ public interface VAppAsyncApi { @Path("/action/exitMaintenanceMode") @Consumes @JAXBResponseParser - ListenableFuture exitMaintenanceMode(@EndpointParam URI vAppURI); + ListenableFuture exitMaintenanceMode(@EndpointParam URI vAppHref); /** * @see VAppApi#recompose(URI, RecomposeVAppParams) @@ -155,8 +435,8 @@ public interface VAppAsyncApi { @Produces(RECOMPOSE_VAPP_PARAMS) @Consumes(TASK) @JAXBResponseParser - ListenableFuture recompose(@EndpointParam URI vAppURI, - @BinderParam(BindToXMLPayload.class) RecomposeVAppParams params); + ListenableFuture recompose(@EndpointParam URI vAppHref, + @BinderParam(BindToXMLPayload.class) RecomposeVAppParams params); /** * @see VAppApi#undeploy(URI, UndeployVAppParams) @@ -166,18 +446,18 @@ public interface VAppAsyncApi { @Produces(UNDEPLOY_VAPP_PARAMS) @Consumes(TASK) @JAXBResponseParser - ListenableFuture undeploy(@EndpointParam URI vAppURI, - @BinderParam(BindToXMLPayload.class) UndeployVAppParams params); + ListenableFuture undeploy(@EndpointParam URI vAppHref, + @BinderParam(BindToXMLPayload.class) UndeployVAppParams params); /** - * @see VAppApi#getControlAccess(URI) + * @see VAppApi#getAccessControl(URI) */ @GET @Path("/controlAccess") @Consumes(CONTROL_ACCESS) @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getControlAccess(@EndpointParam URI vAppURI); + ListenableFuture getAccessControl(@EndpointParam URI vAppHref); /** * @see VAppApi#powerOff(URI) @@ -186,7 +466,7 @@ public interface VAppAsyncApi { @Path("/power/action/powerOff") @Consumes(TASK) @JAXBResponseParser - ListenableFuture powerOff(@EndpointParam URI vAppURI); + ListenableFuture powerOff(@EndpointParam URI vAppHref); /** * @see VAppApi#powerOn(URI) @@ -195,7 +475,7 @@ public interface VAppAsyncApi { @Path("/power/action/powerOn") @Consumes(TASK) @JAXBResponseParser - ListenableFuture powerOn(@EndpointParam URI vAppURI); + ListenableFuture powerOn(@EndpointParam URI vAppHref); /** * @see VAppApi#reboot(URI) @@ -204,7 +484,7 @@ public interface VAppAsyncApi { @Path("/power/action/powerOff") @Consumes(TASK) @JAXBResponseParser - ListenableFuture reboot(@EndpointParam URI vAppURI); + ListenableFuture reboot(@EndpointParam URI vAppHref); /** * @see VAppApi#reset(URI) @@ -213,7 +493,7 @@ public interface VAppAsyncApi { @Path("/power/action/reset") @Consumes(TASK) @JAXBResponseParser - ListenableFuture reset(@EndpointParam URI vAppURI); + ListenableFuture reset(@EndpointParam URI vAppHref); /** * @see VAppApi#shutdown(URI) @@ -222,7 +502,7 @@ public interface VAppAsyncApi { @Path("/power/action/shutdown") @Consumes(TASK) @JAXBResponseParser - ListenableFuture shutdown(@EndpointParam URI vAppURI); + ListenableFuture shutdown(@EndpointParam URI vAppHref); /** * @see VAppApi#suspend(URI) @@ -231,7 +511,7 @@ public interface VAppAsyncApi { @Path("/power/action/suspend") @Consumes(TASK) @JAXBResponseParser - ListenableFuture suspend(@EndpointParam URI vAppURI); + ListenableFuture suspend(@EndpointParam URI vAppHref); /** * @see VAppApi#getLeaseSettingsSection(URI) @@ -241,7 +521,7 @@ public interface VAppAsyncApi { @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getLeaseSettingsSection(@EndpointParam URI vAppURI); + ListenableFuture getLeaseSettingsSection(@EndpointParam URI vAppHref); /** * @see VAppApi#editLeaseSettingsSection(URI, LeaseSettingsSection) @@ -251,8 +531,8 @@ public interface VAppAsyncApi { @Produces(LEASE_SETTINGS_SECTION) @Consumes(TASK) @JAXBResponseParser - ListenableFuture editLeaseSettingsSection(@EndpointParam URI vAppURI, - @BinderParam(BindToXMLPayload.class) LeaseSettingsSection section); + ListenableFuture editLeaseSettingsSection(@EndpointParam URI vAppHref, + @BinderParam(BindToXMLPayload.class) LeaseSettingsSection section); /** * @see VAppApi#getNetworkConfigSection(URI) @@ -262,7 +542,7 @@ public interface VAppAsyncApi { @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getNetworkConfigSection(@EndpointParam URI vAppURI); + ListenableFuture getNetworkConfigSection(@EndpointParam URI vAppHref); /** * @see VAppApi#editNetworkConfigSection(URI, NetworkConfigSection) @@ -272,8 +552,8 @@ public interface VAppAsyncApi { @Produces(NETWORK_CONFIG_SECTION) @Consumes(TASK) @JAXBResponseParser - ListenableFuture editNetworkConfigSection(@EndpointParam URI vAppURI, - @BinderParam(BindToXMLPayload.class) NetworkConfigSection section); + ListenableFuture editNetworkConfigSection(@EndpointParam URI vAppHref, + @BinderParam(BindToXMLPayload.class) NetworkConfigSection section); /** * @see VAppApi#getNetworkSection(URI) @@ -283,7 +563,7 @@ public interface VAppAsyncApi { @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getNetworkSection(@EndpointParam URI vAppURI); + ListenableFuture getNetworkSection(@EndpointParam URI vAppHref); /** * @see VAppApi#getOwner(URI) @@ -293,7 +573,7 @@ public interface VAppAsyncApi { @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getOwner(@EndpointParam URI vAppURI); + ListenableFuture getOwner(@EndpointParam URI vAppHref); /** * @see VAppApi#editOwner(URI, Owner) @@ -303,8 +583,7 @@ public interface VAppAsyncApi { @Produces(OWNER) @Consumes(TASK) @JAXBResponseParser - ListenableFuture editOwner(@EndpointParam URI vAppURI, - @BinderParam(BindToXMLPayload.class) Owner owner); + ListenableFuture editOwner(@EndpointParam URI vAppHref, @BinderParam(BindToXMLPayload.class) Owner owner); /** * @see VAppApi#getProductSections(URI) @@ -314,7 +593,7 @@ public interface VAppAsyncApi { @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getProductSections(@EndpointParam URI vAppURI); + ListenableFuture getProductSections(@EndpointParam URI vAppHref); /** * @see VAppApi#editProductSections(URI, ProductSectionList) @@ -324,9 +603,8 @@ public interface VAppAsyncApi { @Produces(PRODUCT_SECTION_LIST) @Consumes(TASK) @JAXBResponseParser - ListenableFuture editProductSections(@EndpointParam URI vAppURI, - @BinderParam(BindToXMLPayload.class) ProductSectionList sectionList); - + ListenableFuture editProductSections(@EndpointParam URI vAppHref, + @BinderParam(BindToXMLPayload.class) ProductSectionList sectionList); /** * @see VAppApi#getStartupSection(URI) @@ -336,7 +614,7 @@ public interface VAppAsyncApi { @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getStartupSection(@EndpointParam URI vAppURI); + ListenableFuture getStartupSection(@EndpointParam URI vAppHref); /** * @see VAppApi#editStartupSection(URI, StartupSection) @@ -346,12 +624,16 @@ public interface VAppAsyncApi { @Produces(STARTUP_SECTION) @Consumes(TASK) @JAXBResponseParser - ListenableFuture editStartupSection(@EndpointParam URI vAppURI, - @BinderParam(BindToXMLPayload.class) StartupSection section); + ListenableFuture editStartupSection(@EndpointParam URI vAppHref, + @BinderParam(BindToXMLPayload.class) StartupSection section); /** * Asynchronous access to {@link VApp} {@link Metadata} features */ @Delegate - MetadataAsyncApi.Writeable getMetadataApi(); + MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam(parser = VAppURNToHref.class) String vAppUrn); + + @Delegate + MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam URI vAppHref); + } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateApi.java index dbc7b6f9ba..5e962be9dc 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateApi.java @@ -24,56 +24,63 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.dmtf.ovf.NetworkSection; import org.jclouds.rest.annotations.Delegate; +import org.jclouds.rest.annotations.EndpointParam; +import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList; import org.jclouds.vcloud.director.v1_5.domain.References; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.dmtf.Envelope; -import org.jclouds.vcloud.director.v1_5.domain.params.RelocateParams; import org.jclouds.vcloud.director.v1_5.domain.section.CustomizationSection; -import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection; import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection; import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; -import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection; +import org.jclouds.vcloud.director.v1_5.functions.href.VAppTemplateURNToHref; /** * Provides synchronous access to {@link VAppTemplate} objects. * - * @author Adam Lowe - * @see org.jclouds.vcloud.director.v1_5.features.VAppTemplateAsyncApi + * @author Adam Lowe, Adrian Cole + * @see VAppTemplateAsyncApi */ @Timeout(duration = 180, timeUnit = TimeUnit.SECONDS) public interface VAppTemplateApi { /** * Retrieves a vApp template (can be used also to retrieve a VM from a vApp Template). - * + * * The vApp could be in one of these statues: *
    - *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#FAILED_CREATION FAILED_CREATION(-1)} - - * Transient entity state, e.g., model object is addd but the corresponding VC backing does not exist yet. This - * is further sub-categorized in the respective entities. - *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNRESOLVED UNRESOLVED(0)} - - * Entity is whole, e.g., VM creation is complete and all the required model objects and VC backings are addd. - *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#RESOLVED RESOLVED(1)} - - * Entity is resolved. - *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNKNOWN UNKNOWN(6)} - - * Entity state could not be retrieved from the inventory, e.g., VM power state is null. - *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#POWERED_OFF POWERED_OFF(8)} - - * All VMs of the vApp template are powered off. - *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#MIXED MIXED(10)} - - * vApp template status is set to {@code MIXED} when the VMs in the vApp are in different power states. + *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#FAILED_CREATION + * FAILED_CREATION(-1)} - Transient entity state, e.g., model object is addd but the + * corresponding VC backing does not exist yet. This is further sub-categorized in the respective + * entities. + *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNRESOLVED + * UNRESOLVED(0)} - Entity is whole, e.g., VM creation is complete and all the required model + * objects and VC backings are addd. + *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#RESOLVED + * RESOLVED(1)} - Entity is resolved. + *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#UNKNOWN + * UNKNOWN(6)} - Entity state could not be retrieved from the inventory, e.g., VM power state is + * null. + *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#POWERED_OFF + * POWERED_OFF(8)} - All VMs of the vApp template are powered off. + *
  • {@link org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType.Status#MIXED MIXED(10)} + * - vApp template status is set to {@code MIXED} when the VMs in the vApp are in different power + * states. *
* *
     * GET /vAppTemplate/{id}
     * 
* - * @param templateUri the URI of the template + * @param templateUrn + * the String of the template * @return the requested template */ - VAppTemplate getVAppTemplate(URI templateUri); + VAppTemplate get(String templateUrn); + + VAppTemplate get(URI templateHref); /** * Modifies only the name/description of a vApp template. @@ -82,12 +89,16 @@ public interface VAppTemplateApi { * PUT /vAppTemplate/{id} * * - * @param templateUri the URI of the template - * @param template the template containing the new name and/or description - * @return the task performing the action. This operation is asynchronous and the user should monitor the returned - * task status in order to check when it is completed. + * @param templateUrn + * the String of the template + * @param template + * the template containing the new name and/or description + * @return the task performing the action. This operation is asynchronous and the user should + * monitor the returned task status in order to check when it is completed. */ - Task editVAppTemplate(URI templateUri, VAppTemplate template); + Task edit(String templateUrn, VAppTemplate template); + + Task edit(URI templateHref, VAppTemplate template); /** * Deletes a vApp template. @@ -96,24 +107,14 @@ public interface VAppTemplateApi { * DELETE /vAppTemplate/{id} * * - * @param templateUri the URI of the template - * @return the task performing the action. This operation is asynchronous and the user should monitor the returned - * task status in order to check when it is completed. + * @param templateUrn + * the String of the template + * @return the task performing the action. This operation is asynchronous and the user should + * monitor the returned task status in order to check when it is completed. */ - Task removeVappTemplate(URI templateUri); + Task remove(String templateUrn); - /** - * Consolidates a VM - * - *
-    * POST /vAppTemplate/{id}/action/consolidate
-    * 
- * - * @param templateUri the URI of the template - * @return the task performing the action. This operation is asynchronous and the user should monitor the returned - * task status in order to check when it is completed. - */ - Task consolidateVm(URI templateUri); + Task remove(URI templateHref); /** * Disables the download link to the ovf of a vApp template. @@ -122,9 +123,12 @@ public interface VAppTemplateApi { * POST /vAppTemplate/{id}/action/disableDownload * * - * @param templateUri the URI of the template + * @param templateUrn + * the String of the template */ - void disableDownload(URI templateUri); + void disableDownload(String templateUrn); + + void disableDownload(URI templateHref); /** * Enables downloading of the ovf of a vApp template. @@ -133,25 +137,14 @@ public interface VAppTemplateApi { * POST /vAppTemplate/{id}/action/enableDownload * * - * @param templateUri the URI of the template - * @return the task performing the action. This operation is asynchronous and the user should monitor the returned - * task status in order to check when it is completed. + * @param templateUrn + * the String of the template + * @return the task performing the action. This operation is asynchronous and the user should + * monitor the returned task status in order to check when it is completed. */ - Task enableDownload(URI templateUri); + Task enableDownload(String templateUrn); - /** - * Relocates a virtual machine in a vApp template to a different datastore. - * - *
-    * POST /vAppTemplate/{id}/action/relocate
-    * 
- * - * @param templateUri the URI of the template - * @param params contains the reference to the new datastore - * @return the task performing the action. This operation is asynchronous and the user should monitor the returned - * task status in order to check when it is completed. - */ - Task relocateVm(URI templateUri, RelocateParams params); + Task enableDownload(URI templateHref); /** * Retrieves the customization section of a vApp template. @@ -160,36 +153,13 @@ public interface VAppTemplateApi { * GET /vAppTemplate/{id}/customizationSection * * - * @param templateUri the URI of the template + * @param templateUrn + * the String of the template * @return the customization section */ - CustomizationSection getCustomizationSection(URI templateUri); + CustomizationSection getCustomizationSection(String templateUrn); - /** - * Retrieves the Guest Customization Section of a VM - * - *
-    * GET /vAppTemplate/{id}/guestCustomizationSection
-    * 
- * - * @param templateUri the URI of the template - * @return the guest customization section - */ - GuestCustomizationSection getGuestCustomizationSection(URI templateUri); - - /** - * Modifies the guest customization options of a VM. - * - *
-    * PUT /vAppTemplate/{id}/guestCustomizationSection
-    * 
- * - * @param templateUri the URI of the template - * @param section the new configuration to apply - * @return the task performing the action. This operation is asynchronous and the user should monitor the returned - * task status in order to check when it is completed. - */ - Task editGuestCustomizationSection(URI templateUri, GuestCustomizationSection section); + CustomizationSection getCustomizationSection(URI templateHref); /** * Retrieves the lease settings section of a vApp or vApp template @@ -198,10 +168,13 @@ public interface VAppTemplateApi { * GET /vAppTemplate/{id}/leaseSettingsSection * * - * @param templateUri the URI of the template + * @param templateUrn + * the String of the template * @return the lease settings */ - LeaseSettingsSection getLeaseSettingsSection(URI templateUri); + LeaseSettingsSection getLeaseSettingsSection(String templateUrn); + + LeaseSettingsSection getLeaseSettingsSection(URI templateHref); /** * Modifies the lease settings section of a vApp or vApp template. @@ -210,12 +183,16 @@ public interface VAppTemplateApi { * PUT /vAppTemplate/{id}/leaseSettingsSection * * - * @param templateUri the URI of the template - * @param section the new configuration to apply - * @return the task performing the action. This operation is asynchronous and the user should monitor the returned - * task status in order to check when it is completed. + * @param templateUrn + * the String of the template + * @param section + * the new configuration to apply + * @return the task performing the action. This operation is asynchronous and the user should + * monitor the returned task status in order to check when it is completed. */ - Task editLeaseSettingsSection(URI templateUri, LeaseSettingsSection section); + Task editLeaseSettingsSection(String templateUrn, LeaseSettingsSection section); + + Task editLeaseSettingsSection(URI templateHref, LeaseSettingsSection section); /** * Retrieves the network config section of a vApp or vApp template. @@ -224,22 +201,13 @@ public interface VAppTemplateApi { * GET /vAppTemplate/{id}/networkConfigSection * * - * @param templateUri the URI of the template + * @param templateUrn + * the String of the template * @return the network config section requested */ - NetworkConfigSection getNetworkConfigSection(URI templateUri); + NetworkConfigSection getNetworkConfigSection(String templateUrn); - /** - * Retrieves the network connection section of a VM - * - *
-    * GET /vAppTemplate/{id}/networkConnectionSection
-    * 
- * - * @param templateUri the URI of the template - * @return the network connection section requested - */ - NetworkConnectionSection getNetworkConnectionSection(URI templateUri); + NetworkConfigSection getNetworkConfigSection(URI templateHref); /** * Retrieves the network section of a vApp or vApp template. @@ -248,26 +216,32 @@ public interface VAppTemplateApi { * GET /vAppTemplate/{id}/networkSection * * - * @param templateUri the URI of the template + * @param templateUrn + * the String of the template * @return the network section requested */ - NetworkSection getNetworkSection(URI templateUri); + NetworkSection getNetworkSection(String templateUrn); + + NetworkSection getNetworkSection(URI templateHref); /** * Retrieves an OVF descriptor of a vApp template. - * - * This OVF represents the vApp template as it is, with all vCloud specific information (like mac address, parent - * networks, etc). The OVF which could be downloaded by enabling for download will not contain this information. - * There are no specific states bound to this entity. + * + * This OVF represents the vApp template as it is, with all vCloud specific information (like mac + * address, parent networks, etc). The OVF which could be downloaded by enabling for download + * will not contain this information. There are no specific states bound to this entity. * *
     * GET /vAppTemplate/{id}/ovf
     * 
* - * @param templateUri the URI of the template + * @param templateUrn + * the String of the template * @return the ovf envelope */ - Envelope getOvf(URI templateUri); + Envelope getOvf(String templateUrn); + + Envelope getOvf(URI templateHref); /** * Retrieves vApp template owner. @@ -276,10 +250,13 @@ public interface VAppTemplateApi { * GET /vAppTemplate/{id}/owner * * - * @param templateUri the URI of the template + * @param templateUrn + * the String of the template * @return the owner of the vApp template */ - Owner getOwner(URI templateUri); + Owner getOwner(String templateUrn); + + Owner getOwner(URI templateHref); /** * Retrieves VAppTemplate/VM product sections @@ -288,10 +265,13 @@ public interface VAppTemplateApi { * GET /vAppTemplate/{id}/productSections * * - * @param templateUri the URI of the template + * @param templateUrn + * the String of the template * @return the product sections */ - ProductSectionList getProductSections(URI templateUri); + ProductSectionList getProductSections(String templateUrn); + + ProductSectionList getProductSections(URI templateHref); /** * Modifies the product sections of a vApp or vApp template. @@ -300,25 +280,35 @@ public interface VAppTemplateApi { * PUT /vAppTemplate/{id}/productSections * * - * @param templateUri the URI of the template - * @return the task performing the action. This operation is asynchronous and the user should monitor the returned - * task status in order to check when it is completed. + * @param templateUrn + * the String of the template + * @return the task performing the action. This operation is asynchronous and the user should + * monitor the returned task status in order to check when it is completed. */ - Task editProductSections(URI templateUri, ProductSectionList sections); + Task editProductSections(String templateUrn, ProductSectionList sections); + + Task editProductSections(URI templateHref, ProductSectionList sections); /** *
     * GET /vAppTemplate/{id}/shadowVms
     * 
* - * @param templateUri the URI of the template + * @param templateUrn + * the String of the template * @return shadowVM references */ - References getShadowVms(URI templateUri); + References getShadowVms(String templateUrn); + + References getShadowVms(URI templateHref); /** * @return synchronous access to {@link Metadata} features */ @Delegate - MetadataApi.Writeable getMetadataApi(); + MetadataApi.Writeable getMetadataApi(@EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn); + + @Delegate + MetadataApi.Writeable getMetadataApi(@EndpointParam URI templateHref); + } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateAsyncApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateAsyncApi.java index 617453261a..2a28cf7d69 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateAsyncApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateAsyncApi.java @@ -19,14 +19,11 @@ package org.jclouds.vcloud.director.v1_5.features; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.CUSTOMIZATION_SECTION; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.GUEST_CUSTOMIZATION_SECTION; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.LEASE_SETTINGS_SECTION; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NETWORK_CONFIG_SECTION; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NETWORK_CONNECTION_SECTION; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NETWORK_SECTION; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.OWNER; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.PRODUCT_SECTION_LIST; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.RELOCATE_TEMPLATE; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.TASK; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.VAPP_TEMPLATE; @@ -49,65 +46,206 @@ import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.binders.BindToXMLPayload; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList; import org.jclouds.vcloud.director.v1_5.domain.References; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.dmtf.Envelope; -import org.jclouds.vcloud.director.v1_5.domain.params.RelocateParams; import org.jclouds.vcloud.director.v1_5.domain.section.CustomizationSection; -import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection; import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection; import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; -import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationAndCookieToRequest; +import org.jclouds.vcloud.director.v1_5.functions.href.VAppTemplateURNToHref; import com.google.common.util.concurrent.ListenableFuture; /** - * @author Adam Lowe - * @see org.jclouds.vcloud.director.v1_5.features.VAppTemplateApi + * @author Adam Lowe, Adrian Cole + * @see VAppTemplateApi */ @RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class) public interface VAppTemplateAsyncApi { /** - * @see VAppTemplateApi#getVAppTemplate(URI) + * @see VAppTemplateApi#get(String) */ @GET @Consumes(VAPP_TEMPLATE) @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getVAppTemplate(@EndpointParam URI reference); - + ListenableFuture get(@EndpointParam String reference); /** - * @see VAppTemplateApi#editVAppTemplate(URI, VAppTemplate) + * @see VAppTemplateApi#edit(String, VAppTemplate) */ @PUT @Produces(VAPP_TEMPLATE) @Consumes(TASK) @JAXBResponseParser - ListenableFuture editVAppTemplate(@EndpointParam URI templateURI, - @BinderParam(BindToXMLPayload.class) VAppTemplate template); + ListenableFuture edit(@EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn, + @BinderParam(BindToXMLPayload.class) VAppTemplate template); /** - * @see VAppTemplateApi#removeVappTemplate(URI) + * @see VAppTemplateApi#remove(String) */ @DELETE @Consumes(TASK) @JAXBResponseParser - ListenableFuture removeVappTemplate(@EndpointParam URI templateUri); + ListenableFuture remove(@EndpointParam String templateUri); /** - * @see VAppTemplateApi#consolidateVm(URI) + * @see VAppTemplateApi#disableDownload(String) + */ + @POST + @Path("/action/disableDownload") + @JAXBResponseParser + ListenableFuture disableDownload(@EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn); + + /** + * @see VAppTemplateApi#enableDownload(String) */ @POST @Consumes(TASK) - @Path("/action/consolidate") + @Path("/action/enableDownload") @JAXBResponseParser - ListenableFuture consolidateVm(@EndpointParam URI templateURI); + ListenableFuture enableDownload(@EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn); + + /** + * @see VAppTemplateApi#getCustomizationSection(String) + */ + @GET + @Consumes(CUSTOMIZATION_SECTION) + @Path("/customizationSection") + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getCustomizationSection( + @EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn); + + /** + * @see VAppTemplateApi#getLeaseSettingsSection(String) + */ + @GET + @Consumes(LEASE_SETTINGS_SECTION) + @Path("/leaseSettingsSection") + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getLeaseSettingsSection( + @EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn); + + /** + * @see VAppTemplateApi#editLeaseSettingsSection(String, LeaseSettingsSection) + */ + @PUT + @Produces(LEASE_SETTINGS_SECTION) + @Consumes(TASK) + @Path("/leaseSettingsSection") + @JAXBResponseParser + ListenableFuture editLeaseSettingsSection( + @EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn, + @BinderParam(BindToXMLPayload.class) LeaseSettingsSection settingsSection); + + /** + * @see VAppTemplateApi#getNetworkConfigSection(String) + */ + @GET + @Consumes(NETWORK_CONFIG_SECTION) + @Path("/networkConfigSection") + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getNetworkConfigSection( + @EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn); + + /** + * @see VAppTemplateApi#getNetworkSection(String) + */ + @GET + @Consumes(NETWORK_SECTION) + @Path("/networkSection") + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getNetworkSection( + @EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn); + + /** + * @see VAppTemplateApi#getOvf(String) + */ + @GET + @Consumes + @Path("/ovf") + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getOvf(@EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn); + + /** + * @see VAppTemplateApi#getOwnerOfVAppTemplate(String) + */ + @GET + @Consumes(OWNER) + @Path("/owner") + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getOwner(@EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn); + + /** + * @see VAppTemplateApi#getProductSectionsForVAppTemplate(String) + */ + @GET + @Consumes(PRODUCT_SECTION_LIST) + @Path("/productSections") + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getProductSections( + @EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn); + + /** + * @see VAppTemplateApi#editProductSections(String, ProductSectionList) + */ + @PUT + @Produces(PRODUCT_SECTION_LIST) + @Consumes(TASK) + @Path("/productSections") + @JAXBResponseParser + ListenableFuture editProductSections(@EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn, + @BinderParam(BindToXMLPayload.class) ProductSectionList sections); + + /** + * @see VAppTemplateApi#getShadowVms(String) + */ + @GET + @Consumes + @Path("/shadowVms") + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getShadowVms(@EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn); + + /** + * @see VAppTemplateApi#get(URI) + */ + @GET + @Consumes(VAPP_TEMPLATE) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture get(@EndpointParam URI reference); + + /** + * @see VAppTemplateApi#edit(URI, VAppTemplate) + */ + @PUT + @Produces(VAPP_TEMPLATE) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture edit(@EndpointParam URI templateHref, + @BinderParam(BindToXMLPayload.class) VAppTemplate template); + + /** + * @see VAppTemplateApi#remove(URI) + */ + @DELETE + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture remove(@EndpointParam URI templateUri); /** * @see VAppTemplateApi#disableDownload(URI) @@ -115,27 +253,16 @@ public interface VAppTemplateAsyncApi { @POST @Path("/action/disableDownload") @JAXBResponseParser - ListenableFuture disableDownload(@EndpointParam URI templateURI); + ListenableFuture disableDownload(@EndpointParam URI templateHref); /** - * @see VAppTemplateApi#enableDownloadVappTemplate(URI) + * @see VAppTemplateApi#enableDownload(URI) */ @POST @Consumes(TASK) @Path("/action/enableDownload") @JAXBResponseParser - ListenableFuture enableDownload(@EndpointParam URI templateURI); - - /** - * @see VAppTemplateApi#relocateVm(URI, RelocateParams) - */ - @POST - @Produces(RELOCATE_TEMPLATE) - @Consumes(TASK) - @Path("/action/relocate") - @JAXBResponseParser - ListenableFuture relocateVm(@EndpointParam URI templateURI, - @BinderParam(BindToXMLPayload.class) RelocateParams params); + ListenableFuture enableDownload(@EndpointParam URI templateHref); /** * @see VAppTemplateApi#getCustomizationSection(URI) @@ -145,28 +272,7 @@ public interface VAppTemplateAsyncApi { @Path("/customizationSection") @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getCustomizationSection(@EndpointParam URI templateURI); - - /** - * @see VAppTemplateApi#getGuestCustomizationSection(URI) - */ - @GET - @Consumes(GUEST_CUSTOMIZATION_SECTION) - @Path("/guestCustomizationSection") - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getGuestCustomizationSection(@EndpointParam URI templateURI); - - /** - * @see VAppTemplateApi#editGuestCustomizationSection(URI, org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection) - */ - @PUT - @Produces(GUEST_CUSTOMIZATION_SECTION) - @Consumes(TASK) - @Path("/guestCustomizationSection") - @JAXBResponseParser - ListenableFuture editGuestCustomizationSection(@EndpointParam URI templateURI, - @BinderParam(BindToXMLPayload.class) GuestCustomizationSection section); + ListenableFuture getCustomizationSection(@EndpointParam URI templateHref); /** * @see VAppTemplateApi#getLeaseSettingsSection(URI) @@ -176,7 +282,7 @@ public interface VAppTemplateAsyncApi { @Path("/leaseSettingsSection") @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getLeaseSettingsSection(@EndpointParam URI templateURI); + ListenableFuture getLeaseSettingsSection(@EndpointParam URI templateHref); /** * @see VAppTemplateApi#editLeaseSettingsSection(URI, LeaseSettingsSection) @@ -186,18 +292,8 @@ public interface VAppTemplateAsyncApi { @Consumes(TASK) @Path("/leaseSettingsSection") @JAXBResponseParser - ListenableFuture editLeaseSettingsSection(@EndpointParam URI templateURI, - @BinderParam(BindToXMLPayload.class) LeaseSettingsSection settingsSection); - - /** - * @see VAppTemplateApi#getNetworkConnectionSection(URI) - */ - @GET - @Consumes(NETWORK_CONNECTION_SECTION) - @Path("/networkConnectionSection") - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getNetworkConnectionSection(@EndpointParam URI templateURI); + ListenableFuture editLeaseSettingsSection(@EndpointParam URI templateHref, + @BinderParam(BindToXMLPayload.class) LeaseSettingsSection settingsSection); /** * @see VAppTemplateApi#getNetworkConfigSection(URI) @@ -207,17 +303,7 @@ public interface VAppTemplateAsyncApi { @Path("/networkConfigSection") @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getNetworkConfigSection(@EndpointParam URI templateURI); - - /** - * @see VAppTemplateApi#getNetworkConnectionSection(URI) - */ - @GET - @Consumes(NETWORK_CONNECTION_SECTION) - @Path("/networkConnectionSection") - @JAXBResponseParser - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getVAppTemplateNetworkConnectionSection(@EndpointParam URI templateURI); + ListenableFuture getNetworkConfigSection(@EndpointParam URI templateHref); /** * @see VAppTemplateApi#getNetworkSection(URI) @@ -227,7 +313,7 @@ public interface VAppTemplateAsyncApi { @Path("/networkSection") @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getNetworkSection(@EndpointParam URI templateURI); + ListenableFuture getNetworkSection(@EndpointParam URI templateHref); /** * @see VAppTemplateApi#getOvf(URI) @@ -237,7 +323,7 @@ public interface VAppTemplateAsyncApi { @Path("/ovf") @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getOvf(@EndpointParam URI templateURI); + ListenableFuture getOvf(@EndpointParam URI templateHref); /** * @see VAppTemplateApi#getOwnerOfVAppTemplate(URI) @@ -247,7 +333,7 @@ public interface VAppTemplateAsyncApi { @Path("/owner") @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getOwner(@EndpointParam URI templateURI); + ListenableFuture getOwner(@EndpointParam URI templateHref); /** * @see VAppTemplateApi#getProductSectionsForVAppTemplate(URI) @@ -257,7 +343,7 @@ public interface VAppTemplateAsyncApi { @Path("/productSections") @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getProductSections(@EndpointParam URI templateURI); + ListenableFuture getProductSections(@EndpointParam URI templateHref); /** * @see VAppTemplateApi#editProductSections(URI, ProductSectionList) @@ -267,9 +353,9 @@ public interface VAppTemplateAsyncApi { @Consumes(TASK) @Path("/productSections") @JAXBResponseParser - ListenableFuture editProductSections(@EndpointParam URI templateURI, - @BinderParam(BindToXMLPayload.class) ProductSectionList sections); - + ListenableFuture editProductSections(@EndpointParam URI templateHref, + @BinderParam(BindToXMLPayload.class) ProductSectionList sections); + /** * @see VAppTemplateApi#getShadowVms(URI) */ @@ -278,11 +364,15 @@ public interface VAppTemplateAsyncApi { @Path("/shadowVms") @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getShadowVms(@EndpointParam URI templateURI); + ListenableFuture getShadowVms(@EndpointParam URI templateHref); /** * @return asynchronous access to {@link Metadata} features */ @Delegate - MetadataAsyncApi.Writeable getMetadataApi(); + MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam(parser = VAppTemplateURNToHref.class) String templateUrn); + + @Delegate + MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam URI templateHref); + } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcApi.java index 2443305600..1c680fd7f5 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcApi.java @@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; +import org.jclouds.rest.annotations.EndpointParam; 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.VApp; @@ -35,6 +36,7 @@ import org.jclouds.vcloud.director.v1_5.domain.params.CloneVAppTemplateParams; import org.jclouds.vcloud.director.v1_5.domain.params.ComposeVAppParams; import org.jclouds.vcloud.director.v1_5.domain.params.InstantiateVAppParams; import org.jclouds.vcloud.director.v1_5.domain.params.UploadVAppTemplateParams; +import org.jclouds.vcloud.director.v1_5.functions.href.VdcURNToHref; /** * Provides synchronous access to a vDC. @@ -196,5 +198,9 @@ public interface VdcApi { * @return synchronous access to {@link Metadata.Readable} features */ @Delegate - MetadataApi.Readable getMetadataApi(); + MetadataApi.Readable getMetadataApi(@EndpointParam(parser = VdcURNToHref.class) String vdcUrn); + + @Delegate + MetadataApi.Readable getMetadataApi(@EndpointParam URI vdcHref); + } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncApi.java index deee99b7ee..221fc78fa0 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VdcAsyncApi.java @@ -258,6 +258,9 @@ public interface VdcAsyncApi { * @return asynchronous access to {@link Metadata.Readable} features */ @Delegate - MetadataAsyncApi.Readable getMetadataApi(); + MetadataAsyncApi.Readable getMetadataApi(@EndpointParam(parser = VdcURNToHref.class) String vdcUrn); + + @Delegate + MetadataAsyncApi.Readable getMetadataApi(@EndpointParam URI vdcHref); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VmApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VmApi.java index e5a0aed159..afbd3b4a4c 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VmApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VmApi.java @@ -23,6 +23,8 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; +import org.jclouds.rest.annotations.EndpointParam; +import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList; import org.jclouds.vcloud.director.v1_5.domain.RasdItemsList; import org.jclouds.vcloud.director.v1_5.domain.ScreenTicket; @@ -41,11 +43,12 @@ import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection; import org.jclouds.vcloud.director.v1_5.domain.section.OperatingSystemSection; import org.jclouds.vcloud.director.v1_5.domain.section.RuntimeInfoSection; import org.jclouds.vcloud.director.v1_5.domain.section.VirtualHardwareSection; +import org.jclouds.vcloud.director.v1_5.functions.href.VmURNToHref; /** * Provides synchronous access to {@link Vm} objects. - * - * @author grkvlt@apache.org + * + * @author grkvlt@apache.org, Adrian Cole * @see VmAsyncApi * @version 1.5 */ @@ -54,465 +57,561 @@ public interface VmApi { /** * Retrieves a {@link Vm}. - * + * * @since 0.9 - * @see VAppApi#getVApp(URI) + * @see VAppApi#get(String) */ - Vm get(URI vmURI); + Vm get(String vmUrn); + + Vm get(URI vmHref); /** * Modifies the name/description of a {@link Vm}. - * + * * @since 0.9 - * @see VAppApi#editVApp(URI, VApp) + * @see VAppApi#edit(String, VApp) */ - Task edit(URI vmURI, Vm vm); + Task edit(String vmUrn, Vm vm); + + Task edit(URI vmHref, Vm vm); /** * Deletes a {@link Vm}. - * + * * @since 0.9 - * @see VAppApi#removeVApp(URI) + * @see VAppApi#remove(String) */ - Task remove(URI vmURI); + Task remove(String vmUrn); + + Task remove(URI vmHref); /** * Consolidates a {@link Vm}. - * + * *
     * POST /vApp/{id}/action/consolidate
     * 
- * + * * @since 1.5 */ - Task consolidate(URI vmURI); + Task consolidate(String vmUrn); + + Task consolidate(URI vmHref); /** * Deploys a {@link Vm}. - * + * * @since 0.9 - * @see VAppApi#deploy(URI, DeployVAppParams) + * @see VAppApi#deploy(String, DeployVAppParams) */ - Task deploy(URI vmURI, DeployVAppParams params); + Task deploy(String vmUrn, DeployVAppParams params); + + Task deploy(URI vmHref, DeployVAppParams params); /** * Discard suspended state of a {@link Vm}. - * + * * @since 0.9 - * @see VAppApi#discardSuspendedState(URI) + * @see VAppApi#discardSuspendedState(String) */ - Task discardSuspendedState(URI vmURI); + Task discardSuspendedState(String vmUrn); + + Task discardSuspendedState(URI vmHref); /** * Installs VMware tools to the virtual machine. - * + * * It should be running in order for them to be installed. - * + * *
     * POST /vApp/{id}/action/installVMwareTools
     * 
- * + * * @since 1.5 */ - Task installVMwareTools(URI vmURI); + Task installVMwareTools(String vmUrn); + + Task installVMwareTools(URI vmHref); /** * Relocates a {@link Vm}. - * + * *
     * POST /vApp/{id}/action/relocate
     * 
- * + * * @since 1.5 */ - Task relocate(URI vmURI, RelocateParams params); + Task relocate(String vmUrn, RelocateParams params); + + Task relocate(URI vmHref, RelocateParams params); /** * Undeploy a {@link Vm}. - * + * * @since 0.9 - * @see VAppApi#undeploy(URI, UndeployVAppParams) + * @see VAppApi#undeploy(String, UndeployVAppParams) */ - Task undeploy(URI vmURI, UndeployVAppParams params); + Task undeploy(String vmUrn, UndeployVAppParams params); + + Task undeploy(URI vmHref, UndeployVAppParams params); /** - * Upgrade virtual hardware version of a VM to the highest supported virtual - * hardware version of provider vDC where the VM locates. - * + * Upgrade virtual hardware version of a VM to the highest supported virtual hardware version of + * provider vDC where the VM locates. + * *
     * POST /vApp/{id}/action/upgradeHardwareVersion
     * 
- * + * * @since 1.5 */ - Task upgradeHardwareVersion(URI vmURI); + Task upgradeHardwareVersion(String vmUrn); + + Task upgradeHardwareVersion(URI vmHref); /** * Powers off a {@link Vm}. - * + * * @since 0.9 - * @see VAppApi#powerOff(URI) + * @see VAppApi#powerOff(String) */ - Task powerOff(URI vmURI); + Task powerOff(String vmUrn); + + Task powerOff(URI vmHref); /** * Powers on a {@link Vm}. - * + * * @since 0.9 - * @see VAppApi#powerOn(URI) + * @see VAppApi#powerOn(String) */ - Task powerOn(URI vmURI); + Task powerOn(String vmUrn); + + Task powerOn(URI vmHref); /** * Reboots a {@link Vm}. - * + * * @since 0.9 - * @see VAppApi#reboot(URI) + * @see VAppApi#reboot(String) */ - Task reboot(URI vmURI); + Task reboot(String vmUrn); + + Task reboot(URI vmHref); /** * Resets a {@link Vm}. - * + * * @since 0.9 - * @see VAppApi#reset(URI) + * @see VAppApi#reset(String) */ - Task reset(URI vmURI); + Task reset(String vmUrn); + + Task reset(URI vmHref); /** * Shuts down a {@link Vm}. - * + * * @since 0.9 - * @see VAppApi#shutdown(URI) + * @see VAppApi#shutdown(String) */ - Task shutdown(URI vmURI); + Task shutdown(String vmUrn); + + Task shutdown(URI vmHref); /** * Suspends a {@link Vm}. - * + * * @since 0.9 - * @see VAppApi#suspend(URI) + * @see VAppApi#suspend(String) */ - Task suspend(URI vmURI); + Task suspend(String vmUrn); + + Task suspend(URI vmHref); /** * Retrieves the guest customization section of a {@link Vm}. - * + * *
     * GET /vApp/{id}/guestCustomizationSection
     * 
- * + * * @since 1.0 - * @see VAppApi# */ - GuestCustomizationSection getGuestCustomizationSection(URI vmURI); + GuestCustomizationSection getGuestCustomizationSection(String vmUrn); + + GuestCustomizationSection getGuestCustomizationSection(URI vmHref); /** * Modifies the guest customization section of a {@link Vm}. - * + * *
     * PUT /vApp/{id}/guestCustomizationSection
     * 
- * + * * @since 1.0 */ - Task editGuestCustomizationSection(URI vmURI, GuestCustomizationSection section); + Task editGuestCustomizationSection(String vmUrn, GuestCustomizationSection section); + + Task editGuestCustomizationSection(URI vmHref, GuestCustomizationSection section); /** * Ejects media from a {@link Vm}. - * + * *
     * PUT /vApp/{id}/media/action/ejectMedia
     * 
- * + * * @since 0.9 */ - Task ejectMedia(URI vmURI, MediaInsertOrEjectParams mediaParams); + Task ejectMedia(String vmUrn, MediaInsertOrEjectParams mediaParams); + + Task ejectMedia(URI vmHref, MediaInsertOrEjectParams mediaParams); /** * Insert media into a {@link Vm}. - * + * *
     * PUT /vApp/{id}/media/action/insertMedia
     * 
- * + * * @since 0.9 */ - Task insertMedia(URI vmURI, MediaInsertOrEjectParams mediaParams); + Task insertMedia(String vmUrn, MediaInsertOrEjectParams mediaParams); + + Task insertMedia(URI vmHref, MediaInsertOrEjectParams mediaParams); /** * Retrieves the network connection section of a {@link Vm}. - * + * *
     * GET /vApp/{id}/networkConnectionSection
     * 
- * + * * @since 0.9 */ - NetworkConnectionSection getNetworkConnectionSection(URI vmURI); + NetworkConnectionSection getNetworkConnectionSection(String vmUrn); + + NetworkConnectionSection getNetworkConnectionSection(URI vmHref); /** * Modifies the network connection section of a {@link Vm}. - * + * *
     * PUT /vApp/{id}/networkConnectionSection
     * 
- * + * * @since 0.9 */ - Task editNetworkConnectionSection(URI vmURI, NetworkConnectionSection section); + Task editNetworkConnectionSection(String vmUrn, NetworkConnectionSection section); + + Task editNetworkConnectionSection(URI vmHref, NetworkConnectionSection section); /** * Retrieves the operating system section of a {@link Vm}. - * + * *
     * GET /vApp/{id}/operatingSystemSection
     * 
- * + * * @since 0.9 */ - OperatingSystemSection getOperatingSystemSection(URI vmURI); + OperatingSystemSection getOperatingSystemSection(String vmUrn); + + OperatingSystemSection getOperatingSystemSection(URI vmHref); /** * Modifies the operating system section of a {@link Vm}. - * + * *
     * PUT /vApp/{id}/operatingSystemSection
     * 
- * + * * @since 0.9 */ - Task editOperatingSystemSection(URI vmURI, OperatingSystemSection section); + Task editOperatingSystemSection(String vmUrn, OperatingSystemSection section); + + Task editOperatingSystemSection(URI vmHref, OperatingSystemSection section); /** * Retrieves {@link Vm} product sections. - * + * * @since 1.5 - * @see VAppApi#getProductSections(URI) + * @see VAppApi#getProductSections(String) */ - ProductSectionList getProductSections(URI vmURI); + ProductSectionList getProductSections(String vmUrn); + + ProductSectionList getProductSections(URI vmHref); /** * Modifies the product section information of a {@link Vm}. - * + * * @since 1.5 - * @see VAppApi#editProductSections(URI, ProductSectionList) + * @see VAppApi#editProductSections(String, ProductSectionList) */ - Task editProductSections(URI vmURI, ProductSectionList sectionList); + Task editProductSections(String vmUrn, ProductSectionList sectionList); + + Task editProductSections(URI vmHref, ProductSectionList sectionList); /** * Retrieves a pending question for a {@link Vm}. - * - * The user should answer to the question by operation {@link #answerQuestion(URI, VmQuestionAnswer)}. - * Usually questions will be asked when the VM is powering on. - * + * + * The user should answer to the question by operation + * {@link #answerQuestion(String, VmQuestionAnswer)}. Usually questions will be asked when the VM + * is powering on. + * *
     * GET /vApp/{id}/question
     * 
- * + * * @since 0.9 */ - VmPendingQuestion getPendingQuestion(URI vmURI); + VmPendingQuestion getPendingQuestion(String vmUrn); + + VmPendingQuestion getPendingQuestion(URI vmHref); /** * Answer a pending question on a {@link Vm}. - * - * The answer IDs of choice and question should match the ones returned from operation {@link #getPendingQuestion(URI)}. - * + * + * The answer IDs of choice and question should match the ones returned from operation + * {@link #getPendingQuestion(String)}. + * *
     * POST /vApp/{id}/question/action/answer
     * 
- * + * * @since 0.9 */ - void answerQuestion(URI vmURI, VmQuestionAnswer answer); + void answerQuestion(String vmUrn, VmQuestionAnswer answer); + + void answerQuestion(URI vmHref, VmQuestionAnswer answer); /** * Retrieves the runtime info section of a {@link Vm}. - * + * *
     * GET /vApp/{id}/runtimeInfoSection
     * 
- * + * * @since 1.5 */ - RuntimeInfoSection getRuntimeInfoSection(URI vmURI); + RuntimeInfoSection getRuntimeInfoSection(String vmUrn); + + RuntimeInfoSection getRuntimeInfoSection(URI vmHref); /** * Retrieves the thumbnail of the screen of a {@link Vm}. - * + * * The content type of the response may vary (e.g. {@code image/png}, {@code image/gif}). - * + * *
     * GET /vApp/{id}/screen
     * 
- * + * * @since 0.9 */ - byte[] getScreenImage(URI vmURI); + byte[] getScreenImage(String vmUrn); + + byte[] getScreenImage(URI vmHref); /** * Retrieve a screen ticket for remote console connection to a {@link Vm}. - * - * A screen ticket is a string that includes the virtual machine's IP address, its managed object reference, and a string - * that has been encoded as described in RFC 2396. Each VM element in a vApp includes a link where rel="screen:acquireTicket". - * You can use that link to request a screen ticket that you can use with the vmware-vmrc utility to open a VMware Remote - * Console for the virtual machine represented by that VM element. The vApp should be running to get a valid screen ticket. - * + * + * A screen ticket is a string that includes the virtual machine's IP address, its managed object + * reference, and a string that has been encoded as described in RFC 2396. Each VM element in a + * vApp includes a link where rel="screen:acquireTicket". You can use that link to request a + * screen ticket that you can use with the vmware-vmrc utility to open a VMware Remote Console + * for the virtual machine represented by that VM element. The vApp should be running to get a + * valid screen ticket. + * *
     * GET /vApp/{id}/screen/action/acquireTicket
     * 
- * + * * @since 0.9 */ - ScreenTicket getScreenTicket(URI vmURI); + ScreenTicket getScreenTicket(String vmUrn); + + ScreenTicket getScreenTicket(URI vmHref); /** * Retrieves the virtual hardware section of a {@link Vm}. - * + * *
     * GET /vApp/{id}/virtualHardwareSection
     * 
- * + * * @since 0.9 */ - VirtualHardwareSection getVirtualHardwareSection(URI vmURI); + VirtualHardwareSection getVirtualHardwareSection(String vmUrn); + + VirtualHardwareSection getVirtualHardwareSection(URI vmHref); /** * Modifies the virtual hardware section of a {@link Vm}. - * + * *
     * PUT /vApp/{id}/virtualHardwareSection
     * 
- * + * * @since 0.9 */ - Task editVirtualHardwareSection(URI vmURI, VirtualHardwareSection section); + Task editVirtualHardwareSection(String vmUrn, VirtualHardwareSection section); + + Task editVirtualHardwareSection(URI vmHref, VirtualHardwareSection section); /** * Retrieves the CPU properties in virtual hardware section of a {@link Vm}. - * + * *
     * GET /vApp/{id}/virtualHardwareSection/cpu
     * 
- * + * * @since 0.9 */ - RasdItem getVirtualHardwareSectionCpu(URI vmURI); + RasdItem getVirtualHardwareSectionCpu(String vmUrn); + + RasdItem getVirtualHardwareSectionCpu(URI vmHref); /** * Modifies the CPU properties in virtual hardware section of a {@link Vm}. - * + * *
     * PUT /vApp/{id}/virtualHardwareSection/cpu
     * 
- * + * * @since 0.9 */ - Task editVirtualHardwareSectionCpu(URI vmURI, RasdItem rasd); + Task editVirtualHardwareSectionCpu(String vmUrn, RasdItem rasd); + + Task editVirtualHardwareSectionCpu(URI vmHref, RasdItem rasd); /** * Retrieves a list of items for disks from virtual hardware section of a {@link Vm}. - * + * *
     * GET /vApp/{id}/virtualHardwareSection/disks
     * 
- * + * * @since 0.9 */ - RasdItemsList getVirtualHardwareSectionDisks(URI vmURI); + RasdItemsList getVirtualHardwareSectionDisks(String vmUrn); + + RasdItemsList getVirtualHardwareSectionDisks(URI vmHref); /** * Modifies the disks list in virtual hardware section of a {@link Vm}. - * + * *
     * PUT /vApp/{id}/virtualHardwareSection/disks
     * 
- * + * * @since 0.9 */ - Task editVirtualHardwareSectionDisks(URI vmURI, RasdItemsList rasdItemsList); + Task editVirtualHardwareSectionDisks(String vmUrn, RasdItemsList rasdItemsList); + + Task editVirtualHardwareSectionDisks(URI vmHref, RasdItemsList rasdItemsList); /** * Retrieves the list of items that represents the floppies and CD/DVD drives in a {@link Vm}. - * + * *
     * GET /vApp/{id}/virtualHardwareSection/media
     * 
- * + * * @since 0.9 */ - RasdItemsList getVirtualHardwareSectionMedia(URI vmURI); + RasdItemsList getVirtualHardwareSectionMedia(String vmUrn); + + RasdItemsList getVirtualHardwareSectionMedia(URI vmHref); /** - * Retrieves the item that contains memory information from virtual hardware section of a {@link Vm}. - * + * Retrieves the item that contains memory information from virtual hardware section of a + * {@link Vm}. + * *
     * GET /vApp/{id}/virtualHardwareSection/memory
     * 
- * + * * @since 0.9 */ - RasdItem getVirtualHardwareSectionMemory(URI vmURI); + RasdItem getVirtualHardwareSectionMemory(String vmUrn); + + RasdItem getVirtualHardwareSectionMemory(URI vmHref); /** * Modifies the memory properties in virtual hardware section of a {@link Vm}. - * + * *
     * PUT /vApp/{id}/virtualHardwareSection/memory
     * 
- * + * * @since 0.9 */ - Task editVirtualHardwareSectionMemory(URI vmURI, RasdItem rasd); + Task editVirtualHardwareSectionMemory(String vmUrn, RasdItem rasd); + + Task editVirtualHardwareSectionMemory(URI vmHref, RasdItem rasd); /** * Retrieves a list of items for network cards from virtual hardware section of a {@link Vm}. - * + * *
     * GET /vApp/{id}/virtualHardwareSection/networkCards
     * 
- * + * * @since 0.9 */ - RasdItemsList getVirtualHardwareSectionNetworkCards(URI vmURI); + RasdItemsList getVirtualHardwareSectionNetworkCards(String vmUrn); + + RasdItemsList getVirtualHardwareSectionNetworkCards(URI vmHref); /** * Modifies the network cards list in virtual hardware section of a {@link Vm}. - * + * *
     * PUT /vApp/{id}/virtualHardwareSection/networkCards
     * 
- * + * * @since 0.9 */ - Task editVirtualHardwareSectionNetworkCards(URI vmURI, RasdItemsList rasdItemsList); + Task editVirtualHardwareSectionNetworkCards(String vmUrn, RasdItemsList rasdItemsList); + + Task editVirtualHardwareSectionNetworkCards(URI vmHref, RasdItemsList rasdItemsList); /** * Retrieves a list of items for serial ports from virtual hardware section of a {@link Vm}. - * + * *
     * GET /vApp/{id}/virtualHardwareSection/serialPorts
     * 
- * + * * @since 1.5 */ - RasdItemsList getVirtualHardwareSectionSerialPorts(URI vmURI); + RasdItemsList getVirtualHardwareSectionSerialPorts(String vmUrn); + + RasdItemsList getVirtualHardwareSectionSerialPorts(URI vmHref); /** * Modifies the serial ports list in virtual hardware section of a {@link Vm}. - * + * *
     * PUT /vApp/{id}/virtualHardwareSection/serialPorts
     * 
- * + * * @since 1.5 */ - Task editVirtualHardwareSectionSerialPorts(URI vmURI, RasdItemsList rasdItemsList); + Task editVirtualHardwareSectionSerialPorts(String vmUrn, RasdItemsList rasdItemsList); + + Task editVirtualHardwareSectionSerialPorts(URI vmHref, RasdItemsList rasdItemsList); /** * Synchronous access to {@link Vm} {@link Metadata} features. */ @Delegate - MetadataApi.Writeable getMetadataApi(); + MetadataApi.Writeable getMetadataApi(@EndpointParam(parser = VmURNToHref.class) String vmUrn); + + @Delegate + MetadataApi.Writeable getMetadataApi(@EndpointParam URI vmHref); + } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VmAsyncApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VmAsyncApi.java index 7b4198c3f6..efb6cd3fb3 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VmAsyncApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/VmAsyncApi.java @@ -44,6 +44,7 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produces; +import org.jclouds.dmtf.cim.ResourceAllocationSettingData; import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.EndpointParam; @@ -53,6 +54,7 @@ import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.ResponseParser; import org.jclouds.rest.binders.BindToXMLPayload; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; +import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList; import org.jclouds.vcloud.director.v1_5.domain.RasdItemsList; import org.jclouds.vcloud.director.v1_5.domain.ScreenTicket; @@ -72,16 +74,470 @@ import org.jclouds.vcloud.director.v1_5.domain.section.RuntimeInfoSection; import org.jclouds.vcloud.director.v1_5.domain.section.VirtualHardwareSection; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationAndCookieToRequest; import org.jclouds.vcloud.director.v1_5.functions.ReturnPayloadBytes; +import org.jclouds.vcloud.director.v1_5.functions.href.VmURNToHref; import com.google.common.util.concurrent.ListenableFuture; /** - * @author grkvlt@apache.org + * @author grkvlt@apache.org, Adrian Cole * @see VmApi */ @RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class) public interface VmAsyncApi { + /** + * @see VmApi#get(String) + */ + @GET + @Consumes(VM) + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture get(@EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#edit(String, Vm) + */ + @PUT + @Produces(VM) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture edit(@EndpointParam(parser = VmURNToHref.class) String vmUrn, + @BinderParam(BindToXMLPayload.class) Vm vApp); + + /** + * @see VmApi#remove(String) + */ + @DELETE + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture remove(@EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#consolidate(String) + */ + @POST + @Path("/action/consolidate") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture consolidate(@EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#deploy(String, DeployVAppParams) + */ + @POST + @Path("/action/deploy") + @Produces(DEPLOY_VAPP_PARAMS) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture deploy(@EndpointParam(parser = VmURNToHref.class) String vmUrn, + @BinderParam(BindToXMLPayload.class) DeployVAppParams params); + + /** + * @see VmApi#discardSuspendedState(String) + */ + @POST + @Path("/action/discardSuspendedState") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture discardSuspendedState(@EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#installVMwareTools(String) + */ + @POST + @Path("/action/installVMwareTools") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture installVMwareTools(@EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#relocate(String, RelocateParams) + */ + @POST + @Path("/action/relocate") + @Produces(RELOCATE_VM_PARAMS) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture relocate(@EndpointParam(parser = VmURNToHref.class) String vmUrn, + @BinderParam(BindToXMLPayload.class) RelocateParams params); + + /** + * @see VmApi#undeploy(String, UndeployVAppParams) + */ + @POST + @Path("/action/undeploy") + @Produces(UNDEPLOY_VAPP_PARAMS) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture undeploy(@EndpointParam(parser = VmURNToHref.class) String vmUrn, + @BinderParam(BindToXMLPayload.class) UndeployVAppParams params); + + /** + * @see VmApi#upgradeHardwareVersion(String) + */ + @POST + @Path("/action/upgradeHardwareVersion") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture upgradeHardwareVersion(@EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#powerOff(String) + */ + @POST + @Path("/power/action/powerOff") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture powerOff(@EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#powerOn(String) + */ + @POST + @Path("/power/action/powerOn") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture powerOn(@EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#reboot(String) + */ + @POST + @Path("/power/action/powerOff") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture reboot(@EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#reset(String) + */ + @POST + @Path("/power/action/reset") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture reset(@EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#shutdown(String) + */ + @POST + @Path("/power/action/shutdown") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture shutdown(@EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#suspend(String) + */ + @POST + @Path("/power/action/suspend") + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture suspend(@EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#getGuestCustomizationSection(String) + */ + @GET + @Path("/guestCustomizationSection") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getGuestCustomizationSection( + @EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#editGuestCustomizationSection(String, GuestCustomizationSection) + */ + @PUT + @Path("/guestCustomizationSection") + @Produces(GUEST_CUSTOMIZATION_SECTION) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture editGuestCustomizationSection(@EndpointParam(parser = VmURNToHref.class) String vmUrn, + @BinderParam(BindToXMLPayload.class) GuestCustomizationSection section); + + /** + * @see VmApi#ejectMedia(String, MediaInsertOrEjectParams) + */ + @POST + @Path("/media/action/ejectMedia") + @Produces(MEDIA_PARAMS) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture ejectMedia(@EndpointParam(parser = VmURNToHref.class) String vmUrn, + @BinderParam(BindToXMLPayload.class) MediaInsertOrEjectParams mediaParams); + + /** + * @see VmApi#insertMedia(String, MediaInsertOrEjectParams) + */ + @POST + @Path("/media/action/insertMedia") + @Produces(MEDIA_PARAMS) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture insertMedia(@EndpointParam(parser = VmURNToHref.class) String vmUrn, + @BinderParam(BindToXMLPayload.class) MediaInsertOrEjectParams mediaParams); + + /** + * @see VmApi#getNetworkConnectionSection(String) + */ + @GET + @Path("/networkConnectionSection") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getNetworkConnectionSection( + @EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#editNetworkConnectionSection(String, NetworkConnectionSection) + */ + @PUT + @Path("/networkConnectionSection") + @Produces(NETWORK_CONNECTION_SECTION) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture editNetworkConnectionSection(@EndpointParam(parser = VmURNToHref.class) String vmUrn, + @BinderParam(BindToXMLPayload.class) NetworkConnectionSection section); + + /** + * @see VmApi#getOperatingSystemSection(String) + */ + @GET + @Path("/operatingSystemSection") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getOperatingSystemSection( + @EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#editOperatingSystemSection(String, OperatingSystemSection) + */ + @PUT + @Path("/operatingSystemSection") + @Produces(OPERATING_SYSTEM_SECTION) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture editOperatingSystemSection(@EndpointParam(parser = VmURNToHref.class) String vmUrn, + @BinderParam(BindToXMLPayload.class) OperatingSystemSection section); + + /** + * @see VmApi#getProductSections(String) + */ + @GET + @Path("/productSections") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getProductSections(@EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#editProductSections(String, ProductSectionList) + */ + @PUT + @Path("/productSections") + @Produces(PRODUCT_SECTION_LIST) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture editProductSections(@EndpointParam(parser = VmURNToHref.class) String vmUrn, + @BinderParam(BindToXMLPayload.class) ProductSectionList sectionList); + + /** + * @see VmApi#getPendingQuestion(String) + */ + @GET + @Path("/question") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getPendingQuestion(@EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#answerQuestion(String, VmQuestionAnswer) + */ + @POST + @Path("/question/action/answer") + @Produces(VM_PENDING_ANSWER) + @Consumes + @JAXBResponseParser + ListenableFuture answerQuestion(@EndpointParam(parser = VmURNToHref.class) String vmUrn, + @BinderParam(BindToXMLPayload.class) VmQuestionAnswer answer); + + /** + * @see VmApi#getRuntimeInfoSection(String) + */ + @GET + @Path("/runtimeInfoSection") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getRuntimeInfoSection(@EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#getScreenImage(String) + */ + @GET + @Path("/screen") + @Consumes(ANY_IMAGE) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + @ResponseParser(ReturnPayloadBytes.class) + ListenableFuture getScreenImage(@EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#getScreenTicket(String) + */ + @POST + @Path("/screen/action/acquireTicket") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getScreenTicket(@EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#getVirtualHardwareSection(String) + */ + @GET + @Path("/virtualHardwareSection") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getVirtualHardwareSection( + @EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#editVirtualHardwareSection(String, VirtualHardwareSection) + */ + @PUT + @Path("/virtualHardwareSection") + @Produces(VIRTUAL_HARDWARE_SECTION) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture editVirtualHardwareSection(@EndpointParam(parser = VmURNToHref.class) String vmUrn, + @BinderParam(BindToXMLPayload.class) VirtualHardwareSection section); + + /** + * @see VmApi#getVirtualHardwareSectionCpu(String) + */ + @GET + @Path("/virtualHardwareSection/cpu") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getVirtualHardwareSectionCpu(@EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#editVirtualHardwareSectionCpu(String, ResourceAllocationSettingData) + */ + @PUT + @Path("/virtualHardwareSection/cpu") + @Produces(OVF_RASD_ITEM) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture editVirtualHardwareSectionCpu(@EndpointParam(parser = VmURNToHref.class) String vmUrn, + @BinderParam(BindToXMLPayload.class) RasdItem rasd); + + /** + * @see VmApi#getVirtualHardwareSectionDisks(String) + */ + @GET + @Path("/virtualHardwareSection/disks") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getVirtualHardwareSectionDisks( + @EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#editVirtualHardwareSectionDisks(String, RasdItemsList) + */ + @PUT + @Path("/virtualHardwareSection/disks") + @Produces(OVF_RASD_ITEMS_LIST) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture editVirtualHardwareSectionDisks(@EndpointParam(parser = VmURNToHref.class) String vmUrn, + @BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList); + + /** + * @see VmApi#getVirtualHardwareSectionMedia(String) + */ + @GET + @Path("/virtualHardwareSection/media") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getVirtualHardwareSectionMedia( + @EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#getVirtualHardwareSectionMemory(String) + */ + @GET + @Path("/virtualHardwareSection/memory") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getVirtualHardwareSectionMemory(@EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#editVirtualHardwareSectionMemory(String, ResourceAllocationSettingData) + */ + @PUT + @Path("/virtualHardwareSection/memory") + @Produces(OVF_RASD_ITEM) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture editVirtualHardwareSectionMemory(@EndpointParam(parser = VmURNToHref.class) String vmUrn, + @BinderParam(BindToXMLPayload.class) RasdItem rasd); + + /** + * @see VmApi#getVirtualHardwareSectionNetworkCards(String) + */ + @GET + @Path("/virtualHardwareSection/networkCards") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getVirtualHardwareSectionNetworkCards( + @EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#editVirtualHardwareSectionNetworkCards(String, RasdItemsList) + */ + @PUT + @Path("/virtualHardwareSection/networkCards") + @Produces(OVF_RASD_ITEMS_LIST) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture editVirtualHardwareSectionNetworkCards( + @EndpointParam(parser = VmURNToHref.class) String vmUrn, + @BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList); + + /** + * @see VmApi#getVirtualHardwareSectionSerialPorts(String) + */ + @GET + @Path("/virtualHardwareSection/serialPorts") + @Consumes + @JAXBResponseParser + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getVirtualHardwareSectionSerialPorts( + @EndpointParam(parser = VmURNToHref.class) String vmUrn); + + /** + * @see VmApi#editVirtualHardwareSectionSerialPorts(String, RasdItemsList) + */ + @PUT + @Path("/virtualHardwareSection/serialPorts") + @Produces(OVF_RASD_ITEMS_LIST) + @Consumes(TASK) + @JAXBResponseParser + ListenableFuture editVirtualHardwareSectionSerialPorts( + @EndpointParam(parser = VmURNToHref.class) String vmUrn, + @BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList); + /** * @see VmApi#get(URI) */ @@ -89,7 +545,7 @@ public interface VmAsyncApi { @Consumes(VM) @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getVm(@EndpointParam URI vmURI); + ListenableFuture get(@EndpointParam URI vmHref); /** * @see VmApi#edit(URI, Vm) @@ -98,8 +554,7 @@ public interface VmAsyncApi { @Produces(VM) @Consumes(TASK) @JAXBResponseParser - ListenableFuture editVm(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) Vm vApp); + ListenableFuture edit(@EndpointParam URI vmHref, @BinderParam(BindToXMLPayload.class) Vm vApp); /** * @see VmApi#remove(URI) @@ -107,7 +562,7 @@ public interface VmAsyncApi { @DELETE @Consumes(TASK) @JAXBResponseParser - ListenableFuture removeVm(@EndpointParam URI vmURI); + ListenableFuture remove(@EndpointParam URI vmHref); /** * @see VmApi#consolidate(URI) @@ -116,7 +571,7 @@ public interface VmAsyncApi { @Path("/action/consolidate") @Consumes(TASK) @JAXBResponseParser - ListenableFuture consolidateVm(@EndpointParam URI vmURI); + ListenableFuture consolidate(@EndpointParam URI vmHref); /** * @see VmApi#deploy(URI, DeployVAppParams) @@ -126,8 +581,7 @@ public interface VmAsyncApi { @Produces(DEPLOY_VAPP_PARAMS) @Consumes(TASK) @JAXBResponseParser - ListenableFuture deploy(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) DeployVAppParams params); + ListenableFuture deploy(@EndpointParam URI vmHref, @BinderParam(BindToXMLPayload.class) DeployVAppParams params); /** * @see VmApi#discardSuspendedState(URI) @@ -136,7 +590,7 @@ public interface VmAsyncApi { @Path("/action/discardSuspendedState") @Consumes(TASK) @JAXBResponseParser - ListenableFuture discardSuspendedState(@EndpointParam URI vmURI); + ListenableFuture discardSuspendedState(@EndpointParam URI vmHref); /** * @see VmApi#installVMwareTools(URI) @@ -145,7 +599,7 @@ public interface VmAsyncApi { @Path("/action/installVMwareTools") @Consumes(TASK) @JAXBResponseParser - ListenableFuture installVMwareTools(@EndpointParam URI vmURI); + ListenableFuture installVMwareTools(@EndpointParam URI vmHref); /** * @see VmApi#relocate(URI, RelocateParams) @@ -155,8 +609,7 @@ public interface VmAsyncApi { @Produces(RELOCATE_VM_PARAMS) @Consumes(TASK) @JAXBResponseParser - ListenableFuture relocateVm(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) RelocateParams params); + ListenableFuture relocate(@EndpointParam URI vmHref, @BinderParam(BindToXMLPayload.class) RelocateParams params); /** * @see VmApi#undeploy(URI, UndeployVAppParams) @@ -166,8 +619,8 @@ public interface VmAsyncApi { @Produces(UNDEPLOY_VAPP_PARAMS) @Consumes(TASK) @JAXBResponseParser - ListenableFuture undeploy(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) UndeployVAppParams params); + ListenableFuture undeploy(@EndpointParam URI vmHref, + @BinderParam(BindToXMLPayload.class) UndeployVAppParams params); /** * @see VmApi#upgradeHardwareVersion(URI) @@ -176,7 +629,7 @@ public interface VmAsyncApi { @Path("/action/upgradeHardwareVersion") @Consumes(TASK) @JAXBResponseParser - ListenableFuture upgradeHardwareVersion(@EndpointParam URI vmURI); + ListenableFuture upgradeHardwareVersion(@EndpointParam URI vmHref); /** * @see VmApi#powerOff(URI) @@ -185,7 +638,7 @@ public interface VmAsyncApi { @Path("/power/action/powerOff") @Consumes(TASK) @JAXBResponseParser - ListenableFuture powerOff(@EndpointParam URI vmURI); + ListenableFuture powerOff(@EndpointParam URI vmHref); /** * @see VmApi#powerOn(URI) @@ -194,7 +647,7 @@ public interface VmAsyncApi { @Path("/power/action/powerOn") @Consumes(TASK) @JAXBResponseParser - ListenableFuture powerOn(@EndpointParam URI vmURI); + ListenableFuture powerOn(@EndpointParam URI vmHref); /** * @see VmApi#reboot(URI) @@ -203,7 +656,7 @@ public interface VmAsyncApi { @Path("/power/action/powerOff") @Consumes(TASK) @JAXBResponseParser - ListenableFuture reboot(@EndpointParam URI vmURI); + ListenableFuture reboot(@EndpointParam URI vmHref); /** * @see VmApi#reset(URI) @@ -212,7 +665,7 @@ public interface VmAsyncApi { @Path("/power/action/reset") @Consumes(TASK) @JAXBResponseParser - ListenableFuture reset(@EndpointParam URI vmURI); + ListenableFuture reset(@EndpointParam URI vmHref); /** * @see VmApi#shutdown(URI) @@ -221,7 +674,7 @@ public interface VmAsyncApi { @Path("/power/action/shutdown") @Consumes(TASK) @JAXBResponseParser - ListenableFuture shutdown(@EndpointParam URI vmURI); + ListenableFuture shutdown(@EndpointParam URI vmHref); /** * @see VmApi#suspend(URI) @@ -230,7 +683,7 @@ public interface VmAsyncApi { @Path("/power/action/suspend") @Consumes(TASK) @JAXBResponseParser - ListenableFuture suspend(@EndpointParam URI vmURI); + ListenableFuture suspend(@EndpointParam URI vmHref); /** * @see VmApi#getGuestCustomizationSection(URI) @@ -240,7 +693,7 @@ public interface VmAsyncApi { @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getGuestCustomizationSection(@EndpointParam URI vmURI); + ListenableFuture getGuestCustomizationSection(@EndpointParam URI vmHref); /** * @see VmApi#editGuestCustomizationSection(URI, GuestCustomizationSection) @@ -250,8 +703,8 @@ public interface VmAsyncApi { @Produces(GUEST_CUSTOMIZATION_SECTION) @Consumes(TASK) @JAXBResponseParser - ListenableFuture editGuestCustomizationSection(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) GuestCustomizationSection section); + ListenableFuture editGuestCustomizationSection(@EndpointParam URI vmHref, + @BinderParam(BindToXMLPayload.class) GuestCustomizationSection section); /** * @see VmApi#ejectMedia(URI, MediaInsertOrEjectParams) @@ -261,8 +714,8 @@ public interface VmAsyncApi { @Produces(MEDIA_PARAMS) @Consumes(TASK) @JAXBResponseParser - ListenableFuture ejectMedia(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) MediaInsertOrEjectParams mediaParams); + ListenableFuture ejectMedia(@EndpointParam URI vmHref, + @BinderParam(BindToXMLPayload.class) MediaInsertOrEjectParams mediaParams); /** * @see VmApi#insertMedia(URI, MediaInsertOrEjectParams) @@ -272,8 +725,8 @@ public interface VmAsyncApi { @Produces(MEDIA_PARAMS) @Consumes(TASK) @JAXBResponseParser - ListenableFuture insertMedia(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) MediaInsertOrEjectParams mediaParams); + ListenableFuture insertMedia(@EndpointParam URI vmHref, + @BinderParam(BindToXMLPayload.class) MediaInsertOrEjectParams mediaParams); /** * @see VmApi#getNetworkConnectionSection(URI) @@ -283,7 +736,7 @@ public interface VmAsyncApi { @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getNetworkConnectionSection(@EndpointParam URI vmURI); + ListenableFuture getNetworkConnectionSection(@EndpointParam URI vmHref); /** * @see VmApi#editNetworkConnectionSection(URI, NetworkConnectionSection) @@ -293,8 +746,8 @@ public interface VmAsyncApi { @Produces(NETWORK_CONNECTION_SECTION) @Consumes(TASK) @JAXBResponseParser - ListenableFuture editNetworkConnectionSection(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) NetworkConnectionSection section); + ListenableFuture editNetworkConnectionSection(@EndpointParam URI vmHref, + @BinderParam(BindToXMLPayload.class) NetworkConnectionSection section); /** * @see VmApi#getOperatingSystemSection(URI) @@ -304,7 +757,7 @@ public interface VmAsyncApi { @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getOperatingSystemSection(@EndpointParam URI vmURI); + ListenableFuture getOperatingSystemSection(@EndpointParam URI vmHref); /** * @see VmApi#editOperatingSystemSection(URI, OperatingSystemSection) @@ -314,8 +767,8 @@ public interface VmAsyncApi { @Produces(OPERATING_SYSTEM_SECTION) @Consumes(TASK) @JAXBResponseParser - ListenableFuture editOperatingSystemSection(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) OperatingSystemSection section); + ListenableFuture editOperatingSystemSection(@EndpointParam URI vmHref, + @BinderParam(BindToXMLPayload.class) OperatingSystemSection section); /** * @see VmApi#getProductSections(URI) @@ -325,7 +778,7 @@ public interface VmAsyncApi { @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getProductSections(@EndpointParam URI vmURI); + ListenableFuture getProductSections(@EndpointParam URI vmHref); /** * @see VmApi#editProductSections(URI, ProductSectionList) @@ -335,8 +788,8 @@ public interface VmAsyncApi { @Produces(PRODUCT_SECTION_LIST) @Consumes(TASK) @JAXBResponseParser - ListenableFuture editProductSections(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) ProductSectionList sectionList); + ListenableFuture editProductSections(@EndpointParam URI vmHref, + @BinderParam(BindToXMLPayload.class) ProductSectionList sectionList); /** * @see VmApi#getPendingQuestion(URI) @@ -346,7 +799,7 @@ public interface VmAsyncApi { @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getPendingQuestion(@EndpointParam URI vmURI); + ListenableFuture getPendingQuestion(@EndpointParam URI vmHref); /** * @see VmApi#answerQuestion(URI, VmQuestionAnswer) @@ -356,8 +809,8 @@ public interface VmAsyncApi { @Produces(VM_PENDING_ANSWER) @Consumes @JAXBResponseParser - ListenableFuture answerQuestion(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) VmQuestionAnswer answer); + ListenableFuture answerQuestion(@EndpointParam URI vmHref, + @BinderParam(BindToXMLPayload.class) VmQuestionAnswer answer); /** * @see VmApi#getRuntimeInfoSection(URI) @@ -367,7 +820,7 @@ public interface VmAsyncApi { @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getRuntimeInfoSection(@EndpointParam URI vmURI); + ListenableFuture getRuntimeInfoSection(@EndpointParam URI vmHref); /** * @see VmApi#getScreenImage(URI) @@ -377,7 +830,7 @@ public interface VmAsyncApi { @Consumes(ANY_IMAGE) @ExceptionParser(ReturnNullOnNotFoundOr404.class) @ResponseParser(ReturnPayloadBytes.class) - ListenableFuture getScreenImage(@EndpointParam URI vmURI); + ListenableFuture getScreenImage(@EndpointParam URI vmHref); /** * @see VmApi#getScreenTicket(URI) @@ -387,7 +840,7 @@ public interface VmAsyncApi { @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getScreenTicket(@EndpointParam URI vmURI); + ListenableFuture getScreenTicket(@EndpointParam URI vmHref); /** * @see VmApi#getVirtualHardwareSection(URI) @@ -397,7 +850,7 @@ public interface VmAsyncApi { @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getVirtualHardwareSection(@EndpointParam URI vmURI); + ListenableFuture getVirtualHardwareSection(@EndpointParam URI vmHref); /** * @see VmApi#editVirtualHardwareSection(URI, VirtualHardwareSection) @@ -407,8 +860,8 @@ public interface VmAsyncApi { @Produces(VIRTUAL_HARDWARE_SECTION) @Consumes(TASK) @JAXBResponseParser - ListenableFuture editVirtualHardwareSection(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) VirtualHardwareSection section); + ListenableFuture editVirtualHardwareSection(@EndpointParam URI vmHref, + @BinderParam(BindToXMLPayload.class) VirtualHardwareSection section); /** * @see VmApi#getVirtualHardwareSectionCpu(URI) @@ -418,7 +871,7 @@ public interface VmAsyncApi { @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getVirtualHardwareSectionCpu(@EndpointParam URI vmURI); + ListenableFuture getVirtualHardwareSectionCpu(@EndpointParam URI vmHref); /** * @see VmApi#editVirtualHardwareSectionCpu(URI, ResourceAllocationSettingData) @@ -428,8 +881,8 @@ public interface VmAsyncApi { @Produces(OVF_RASD_ITEM) @Consumes(TASK) @JAXBResponseParser - ListenableFuture editVirtualHardwareSectionCpu(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) RasdItem rasd); + ListenableFuture editVirtualHardwareSectionCpu(@EndpointParam URI vmHref, + @BinderParam(BindToXMLPayload.class) RasdItem rasd); /** * @see VmApi#getVirtualHardwareSectionDisks(URI) @@ -439,7 +892,7 @@ public interface VmAsyncApi { @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getVirtualHardwareSectionDisks(@EndpointParam URI vmURI); + ListenableFuture getVirtualHardwareSectionDisks(@EndpointParam URI vmHref); /** * @see VmApi#editVirtualHardwareSectionDisks(URI, RasdItemsList) @@ -449,8 +902,8 @@ public interface VmAsyncApi { @Produces(OVF_RASD_ITEMS_LIST) @Consumes(TASK) @JAXBResponseParser - ListenableFuture editVirtualHardwareSectionDisks(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList); + ListenableFuture editVirtualHardwareSectionDisks(@EndpointParam URI vmHref, + @BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList); /** * @see VmApi#getVirtualHardwareSectionMedia(URI) @@ -460,7 +913,7 @@ public interface VmAsyncApi { @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getVirtualHardwareSectionMedia(@EndpointParam URI vmURI); + ListenableFuture getVirtualHardwareSectionMedia(@EndpointParam URI vmHref); /** * @see VmApi#getVirtualHardwareSectionMemory(URI) @@ -470,7 +923,7 @@ public interface VmAsyncApi { @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getVirtualHardwareSectionMemory(@EndpointParam URI vmURI); + ListenableFuture getVirtualHardwareSectionMemory(@EndpointParam URI vmHref); /** * @see VmApi#editVirtualHardwareSectionMemory(URI, ResourceAllocationSettingData) @@ -480,8 +933,8 @@ public interface VmAsyncApi { @Produces(OVF_RASD_ITEM) @Consumes(TASK) @JAXBResponseParser - ListenableFuture editVirtualHardwareSectionMemory(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) RasdItem rasd); + ListenableFuture editVirtualHardwareSectionMemory(@EndpointParam URI vmHref, + @BinderParam(BindToXMLPayload.class) RasdItem rasd); /** * @see VmApi#getVirtualHardwareSectionNetworkCards(URI) @@ -491,7 +944,7 @@ public interface VmAsyncApi { @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getVirtualHardwareSectionNetworkCards(@EndpointParam URI vmURI); + ListenableFuture getVirtualHardwareSectionNetworkCards(@EndpointParam URI vmHref); /** * @see VmApi#editVirtualHardwareSectionNetworkCards(URI, RasdItemsList) @@ -501,8 +954,8 @@ public interface VmAsyncApi { @Produces(OVF_RASD_ITEMS_LIST) @Consumes(TASK) @JAXBResponseParser - ListenableFuture editVirtualHardwareSectionNetworkCards(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList); + ListenableFuture editVirtualHardwareSectionNetworkCards(@EndpointParam URI vmHref, + @BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList); /** * @see VmApi#getVirtualHardwareSectionSerialPorts(URI) @@ -512,7 +965,7 @@ public interface VmAsyncApi { @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getVirtualHardwareSectionSerialPorts(@EndpointParam URI vmURI); + ListenableFuture getVirtualHardwareSectionSerialPorts(@EndpointParam URI vmHref); /** * @see VmApi#editVirtualHardwareSectionSerialPorts(URI, RasdItemsList) @@ -522,12 +975,16 @@ public interface VmAsyncApi { @Produces(OVF_RASD_ITEMS_LIST) @Consumes(TASK) @JAXBResponseParser - ListenableFuture editVirtualHardwareSectionSerialPorts(@EndpointParam URI vmURI, - @BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList); + ListenableFuture editVirtualHardwareSectionSerialPorts(@EndpointParam URI vmHref, + @BinderParam(BindToXMLPayload.class) RasdItemsList rasdItemsList); /** * Asynchronous access to {@Vm} {@link Metadata} features. */ @Delegate - MetadataAsyncApi.Writeable getMetadataApi(); + MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam(parser = VmURNToHref.class) String vmUrn); + + @Delegate + MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam URI vmHref); + } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogApi.java index a94f03ed57..45937d928a 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogApi.java @@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; +import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.Owner; @@ -30,6 +31,7 @@ import org.jclouds.vcloud.director.v1_5.domain.params.ControlAccessParams; import org.jclouds.vcloud.director.v1_5.domain.params.PublishCatalogParams; import org.jclouds.vcloud.director.v1_5.features.CatalogApi; import org.jclouds.vcloud.director.v1_5.features.MetadataApi; +import org.jclouds.vcloud.director.v1_5.functions.href.CatalogURNToAdminHref; /** * Provides synchronous access to {@link AdminCatalog} objects. @@ -166,5 +168,10 @@ public interface AdminCatalogApi extends CatalogApi { */ @Override @Delegate - MetadataApi.Writeable getMetadataApi(); + MetadataApi.Writeable getMetadataApi(@EndpointParam(parser = CatalogURNToAdminHref.class) String catalogUrn); + + @Override + @Delegate + MetadataApi.Writeable getMetadataApi(@EndpointParam URI catalogAdminHref); + } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogAsyncApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogAsyncApi.java index 2fbed2b9d7..7c42a91722 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogAsyncApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminCatalogAsyncApi.java @@ -248,6 +248,10 @@ public interface AdminCatalogAsyncApi extends CatalogAsyncApi { */ @Override @Delegate - MetadataAsyncApi.Writeable getMetadataApi(); + MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam(parser = CatalogURNToAdminHref.class) String catalogUrn); + + @Override + @Delegate + MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam URI catalogAdminHref); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkApi.java index 94b2634ad8..4b9a4ebc99 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkApi.java @@ -23,11 +23,13 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; +import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.network.Network; import org.jclouds.vcloud.director.v1_5.domain.org.OrgNetwork; import org.jclouds.vcloud.director.v1_5.features.MetadataApi; import org.jclouds.vcloud.director.v1_5.features.NetworkApi; +import org.jclouds.vcloud.director.v1_5.functions.href.NetworkURNToAdminHref; /** * Provides synchronous access to admin {@link Network} objects. @@ -97,6 +99,10 @@ public interface AdminNetworkApi extends NetworkApi { */ @Override @Delegate - MetadataApi.Writeable getMetadataApi(); + MetadataApi.Writeable getMetadataApi(@EndpointParam(parser = NetworkURNToAdminHref.class) String networkUrn); + + @Override + @Delegate + MetadataApi.Writeable getMetadataApi(@EndpointParam URI networkAdminHref); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkAsyncApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkAsyncApi.java index 65b43b1a64..5d42274ebd 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkAsyncApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminNetworkAsyncApi.java @@ -116,5 +116,10 @@ public interface AdminNetworkAsyncApi extends NetworkAsyncApi { */ @Override @Delegate - MetadataAsyncApi.Writeable getMetadataApi(); + MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam(parser = NetworkURNToAdminHref.class) String networkUrn); + + @Override + @Delegate + MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam URI networkAdminHref); + } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgApi.java index 960c44e4ed..3622e2927f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgApi.java @@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; +import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.vcloud.director.v1_5.domain.org.AdminOrg; import org.jclouds.vcloud.director.v1_5.domain.org.Org; import org.jclouds.vcloud.director.v1_5.domain.org.OrgEmailSettings; @@ -34,6 +35,7 @@ import org.jclouds.vcloud.director.v1_5.domain.org.OrgSettings; import org.jclouds.vcloud.director.v1_5.domain.org.OrgVAppTemplateLeaseSettings; import org.jclouds.vcloud.director.v1_5.features.MetadataApi; import org.jclouds.vcloud.director.v1_5.features.OrgApi; +import org.jclouds.vcloud.director.v1_5.functions.href.OrgURNToAdminHref; /** * Provides synchronous access to {@link Org} objects. @@ -274,6 +276,10 @@ public interface AdminOrgApi extends OrgApi { */ @Override @Delegate - MetadataApi.Writeable getMetadataApi(); + MetadataApi.Writeable getMetadataApi(@EndpointParam(parser = OrgURNToAdminHref.class) String orgUrn); + + @Override + @Delegate + MetadataApi.Writeable getMetadataApi(@EndpointParam URI orgAdminHref); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgAsyncApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgAsyncApi.java index 0d1d1664c1..bc7be01c1f 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgAsyncApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminOrgAsyncApi.java @@ -363,5 +363,10 @@ public interface AdminOrgAsyncApi extends OrgAsyncApi { */ @Override @Delegate - MetadataAsyncApi.Writeable getMetadataApi(); + MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam(parser = OrgURNToAdminHref.class) String orgUrn); + + @Override + @Delegate + MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam URI adminOrgHref); + } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcApi.java index bbadaf5750..14e0c83029 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcApi.java @@ -23,11 +23,13 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; +import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.vcloud.director.v1_5.domain.AdminVdc; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.features.MetadataApi; import org.jclouds.vcloud.director.v1_5.features.MetadataApi.Writeable; import org.jclouds.vcloud.director.v1_5.features.VdcApi; +import org.jclouds.vcloud.director.v1_5.functions.href.VdcURNToAdminHref; /** * Provides synchronous access to {@link AdminVdc}. @@ -51,7 +53,7 @@ public interface AdminVdcApi extends VdcApi { AdminVdc get(String vdcUrn); @Override - AdminVdc get(URI vdcHref); + AdminVdc get(URI vdcAdminHref); /** * Modifies a Virtual Data Center. Virtual Data Center could be enabled or disabled. @@ -60,7 +62,7 @@ public interface AdminVdcApi extends VdcApi { */ Task edit(String vdcUrn, AdminVdc vdc); - Task edit(URI vdcHref, AdminVdc vdc); + Task edit(URI vdcAdminHref, AdminVdc vdc); /** * Deletes a Virtual Data Center. The Virtual Data Center should be disabled when remove is issued. @@ -69,7 +71,7 @@ public interface AdminVdcApi extends VdcApi { // TODO Saw what exception, instead of 400 Task remove(String vdcUrn); - Task remove(URI vdcHref); + Task remove(URI vdcAdminHref); /** * Enables a Virtual Data Center. This operation enables disabled Virtual Data Center. @@ -77,7 +79,7 @@ public interface AdminVdcApi extends VdcApi { */ void enable(String vdcUrn); - void enable(URI vdcHref); + void enable(URI vdcAdminHref); /** * Disables a Virtual Data Center. If the Virtual Data Center is disabled this operation does not @@ -85,11 +87,15 @@ public interface AdminVdcApi extends VdcApi { */ void disable(String vdcUrn); - void disable(URI vdcHref); + void disable(URI vdcAdminHref); /** * @return synchronous access to {@link Writeable} features */ @Delegate - MetadataApi.Writeable getMetadataApi(); + MetadataApi.Writeable getMetadataApi(@EndpointParam(parser = VdcURNToAdminHref.class) String vdcUrn); + + @Delegate + MetadataApi.Writeable getMetadataApi(@EndpointParam URI vdcAdminHref); + } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcAsyncApi.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcAsyncApi.java index 4d1cc6f21f..5f192f5281 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcAsyncApi.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcAsyncApi.java @@ -104,7 +104,7 @@ public interface AdminVdcAsyncApi extends VdcAsyncApi { @Consumes @JAXBResponseParser @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture get(@EndpointParam URI vdcHref); + ListenableFuture get(@EndpointParam URI vdcAdminHref); /** * @see AdminVdcApi#edit(URI, AdminVdc) @@ -113,7 +113,7 @@ public interface AdminVdcAsyncApi extends VdcAsyncApi { @Consumes @Produces(VCloudDirectorMediaType.ADMIN_VDC) @JAXBResponseParser - ListenableFuture edit(@EndpointParam URI vdcHref, AdminVdc vdc); + ListenableFuture edit(@EndpointParam URI vdcAdminHref, AdminVdc vdc); /** * @see AdminVdcApi#remove(URI) @@ -121,7 +121,7 @@ public interface AdminVdcAsyncApi extends VdcAsyncApi { @DELETE @Consumes @JAXBResponseParser - ListenableFuture remove(@EndpointParam URI vdcHref); + ListenableFuture remove(@EndpointParam URI vdcAdminHref); /** * @see AdminVdcApi#enable(URI) @@ -130,7 +130,7 @@ public interface AdminVdcAsyncApi extends VdcAsyncApi { @Consumes @Path("/action/enable") @JAXBResponseParser - ListenableFuture enable(@EndpointParam URI vdcHref); + ListenableFuture enable(@EndpointParam URI vdcAdminHref); /** * @see AdminVdcApi#disable(URI) @@ -139,12 +139,17 @@ public interface AdminVdcAsyncApi extends VdcAsyncApi { @Consumes @Path("/action/disable") @JAXBResponseParser - ListenableFuture disable(@EndpointParam URI vdcHref); + ListenableFuture disable(@EndpointParam URI vdcAdminHref); /** * @return asynchronous access to {@link Writeable} features */ @Override @Delegate - MetadataAsyncApi.Writeable getMetadataApi(); + MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam(parser = VdcURNToAdminHref.class) String vdcUrn); + + @Override + @Delegate + MetadataAsyncApi.Writeable getMetadataApi(@EndpointParam URI vdcAdminHref); + } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/VAppTemplatesForCatalogItems.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/VAppTemplatesForCatalogItems.java index dbe94a22f6..2548d3d9e4 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/VAppTemplatesForCatalogItems.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/VAppTemplatesForCatalogItems.java @@ -90,7 +90,7 @@ public class VAppTemplatesForCatalogItems implements Function apply(CatalogItem from) { return new ExceptionParsingListenableFuture(Futures.makeListenable(VCloudDirectorAsyncApi.class - .cast(aapi).getVAppTemplateApi().getVAppTemplate(from.getEntity().getHref()), executor), + .cast(aapi).getVAppTemplateApi().get(from.getEntity().getHref()), executor), returnNullOnAuthorizationException); } diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/href/MediaURNToHref.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/href/MediaURNToHref.java new file mode 100644 index 0000000000..929e6dc1b1 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/href/MediaURNToHref.java @@ -0,0 +1,43 @@ +/* + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.vcloud.director.v1_5.functions.href; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; +import org.jclouds.vcloud.director.v1_5.domain.Entity; +import org.jclouds.vcloud.director.v1_5.functions.URNToHref; + +import com.google.common.cache.LoadingCache; + +@Singleton +public class MediaURNToHref extends URNToHref { + + @Inject + public MediaURNToHref(LoadingCache resolveEntityCache) { + super(resolveEntityCache); + } + + @Override + protected String type() { + return VCloudDirectorMediaType.MEDIA; + } + +} \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/href/VAppTemplateURNToHref.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/href/VAppTemplateURNToHref.java new file mode 100644 index 0000000000..eb6c831fb0 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/href/VAppTemplateURNToHref.java @@ -0,0 +1,43 @@ +/* + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.vcloud.director.v1_5.functions.href; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; +import org.jclouds.vcloud.director.v1_5.domain.Entity; +import org.jclouds.vcloud.director.v1_5.functions.URNToHref; + +import com.google.common.cache.LoadingCache; + +@Singleton +public class VAppTemplateURNToHref extends URNToHref { + + @Inject + public VAppTemplateURNToHref(LoadingCache resolveEntityCache) { + super(resolveEntityCache); + } + + @Override + protected String type() { + return VCloudDirectorMediaType.VAPP_TEMPLATE; + } + +} \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/href/VAppURNToHref.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/href/VAppURNToHref.java new file mode 100644 index 0000000000..85ac172ae5 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/href/VAppURNToHref.java @@ -0,0 +1,43 @@ +/* + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.vcloud.director.v1_5.functions.href; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; +import org.jclouds.vcloud.director.v1_5.domain.Entity; +import org.jclouds.vcloud.director.v1_5.functions.URNToHref; + +import com.google.common.cache.LoadingCache; + +@Singleton +public class VAppURNToHref extends URNToHref { + + @Inject + public VAppURNToHref(LoadingCache resolveEntityCache) { + super(resolveEntityCache); + } + + @Override + protected String type() { + return VCloudDirectorMediaType.VAPP; + } + +} \ No newline at end of file diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/href/VmURNToHref.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/href/VmURNToHref.java new file mode 100644 index 0000000000..0aa18ef573 --- /dev/null +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/functions/href/VmURNToHref.java @@ -0,0 +1,43 @@ +/* + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.jclouds.vcloud.director.v1_5.functions.href; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; +import org.jclouds.vcloud.director.v1_5.domain.Entity; +import org.jclouds.vcloud.director.v1_5.functions.URNToHref; + +import com.google.common.cache.LoadingCache; + +@Singleton +public class VmURNToHref extends URNToHref { + + @Inject + public VmURNToHref(LoadingCache resolveEntityCache) { + super(resolveEntityCache); + } + + @Override + protected String type() { + return VCloudDirectorMediaType.VM; + } + +} \ No newline at end of file diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppApiLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppApiLiveTest.java index 9d92e8a980..1be4816395 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppApiLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppApiLiveTest.java @@ -107,8 +107,8 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT protected Vm vm; protected VApp vApp; protected VAppTemplate vAppTemplate; - protected URI vmURI; - protected URI vAppURI; + protected String vmUrn; + protected String vAppUrn; /** * Retrieves the required apis from the REST API context @@ -137,35 +137,35 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT vdc = lazyGetVdc(); // Get the configured VAppTemplate for the tests - vAppTemplate = vAppTemplateApi.getVAppTemplate(vAppTemplateURI); + vAppTemplate = vAppTemplateApi.get(vAppTemplateUrn); assertNotNull(vAppTemplate, String.format(ENTITY_NON_NULL, VAPP_TEMPLATE)); // Instantiate a new VApp VApp vAppInstantiated = instantiateVApp(); assertNotNull(vAppInstantiated, String.format(ENTITY_NON_NULL, VAPP)); - vAppURI = vAppInstantiated.getHref(); + vAppUrn = vAppInstantiated.getId(); // Wait for the task to complete Task instantiateTask = Iterables.getOnlyElement(vAppInstantiated.getTasks()); assertTrue(retryTaskSuccessLong.apply(instantiateTask), String.format(TASK_COMPLETE_TIMELY, "instantiateTask")); // Get the instantiated VApp - vApp = vAppApi.getVApp(vAppURI); + vApp = vAppApi.get(vAppUrn); // Get the Vm List vms = vApp.getChildren().getVms(); vm = Iterables.getOnlyElement(vms); - vmURI = vm.getHref(); + vmUrn = vm.getId(); assertFalse(vms.isEmpty(), "The VApp must have a Vm"); } - protected void getGuestCustomizationSection(final Function getGuestCustomizationSection) { + protected void getGuestCustomizationSection(final Function getGuestCustomizationSection) { // Get URI for child VM - URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref(); + String vmUrn = Iterables.getOnlyElement(vApp.getChildren().getVms()).getId(); // The method under test try { - GuestCustomizationSection section = getGuestCustomizationSection.apply(vmURI); + GuestCustomizationSection section = getGuestCustomizationSection.apply(vmUrn); // Check the retrieved object is well formed checkGuestCustomizationSection(section); @@ -174,13 +174,13 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT } } - protected void getNetworkConnectionSection(final Function getNetworkConnectionSection) { + protected void getNetworkConnectionSection(final Function getNetworkConnectionSection) { // Get URI for child VM - URI vmURI = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref(); + String vmUrn = Iterables.getOnlyElement(vApp.getChildren().getVms()).getId(); // The method under test try { - NetworkConnectionSection section = getNetworkConnectionSection.apply(vmURI); + NetworkConnectionSection section = getNetworkConnectionSection.apply(vmUrn); // Check the retrieved object is well formed checkNetworkConnectionSection(section); @@ -200,7 +200,7 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT // If we found any references, remove the VApp they point to if (!Iterables.isEmpty(vApps)) { for (Reference ref : vApps) { - cleanUpVApp(ref.getHref()); // NOTE may fail, but should continue deleting + cleanUpVApp(context.getApi().getVAppApi().get(ref.getHref())); // NOTE may fail, but should continue deleting } } else { logger.warn("No VApps in list found in Vdc %s (%s)", vdc.getName(), Iterables.toString(vAppNames)); @@ -248,14 +248,14 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT /** * Power on a {@link VApp}. */ - protected VApp powerOnVApp(final URI testVAppURI) { - VApp test = vAppApi.getVApp(testVAppURI); + protected VApp powerOnVApp(String vAppUrn) { + VApp test = vAppApi.get(vAppUrn); Status status = test.getStatus(); if (status != Status.POWERED_ON) { - Task powerOn = vAppApi.powerOn(vm.getHref()); + Task powerOn = vAppApi.powerOn(vAppUrn); assertTaskSucceedsLong(powerOn); } - test = vAppApi.getVApp(testVAppURI); + test = vAppApi.get(vAppUrn); assertStatus(VAPP, test, Status.POWERED_ON); return test; } @@ -263,14 +263,14 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT /** * Power on a {@link Vm}. */ - protected Vm powerOnVm(final URI testVmURI) { - Vm test = vmApi.get(testVmURI); + protected Vm powerOnVm(String vmUrn) { + Vm test = vmApi.get(vmUrn); Status status = test.getStatus(); if (status != Status.POWERED_ON) { - Task powerOn = vmApi.powerOn(vm.getHref()); + Task powerOn = vmApi.powerOn(vmUrn); assertTaskSucceedsLong(powerOn); } - test = vmApi.get(testVmURI); + test = vmApi.get(vmUrn); assertStatus(VM, test, Status.POWERED_ON); return test; } @@ -278,14 +278,14 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT /** * Power off a {@link VApp}. */ - protected VApp powerOffVApp(final URI testVAppURI) { - VApp test = vAppApi.getVApp(testVAppURI); + protected VApp powerOffVApp(String vAppUrn) { + VApp test = vAppApi.get(vAppUrn); Status status = test.getStatus(); if (status != Status.POWERED_OFF) { - Task powerOff = vAppApi.powerOff(vm.getHref()); + Task powerOff = vAppApi.powerOff(vAppUrn); assertTaskSucceedsLong(powerOff); } - test = vAppApi.getVApp(testVAppURI); + test = vAppApi.get(vAppUrn); assertStatus(VAPP, test, Status.POWERED_OFF); return test; } @@ -293,15 +293,15 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT /** * Power off a {@link Vm}. */ - protected Vm powerOffVm(final URI testVmURI) { - Vm test = vmApi.get(testVmURI); + protected Vm powerOffVm(String vmUrn) { + Vm test = vmApi.get(vmUrn); Status status = test.getStatus(); if (status != Status.POWERED_OFF || test.isDeployed()) { UndeployVAppParams undeployParams = UndeployVAppParams.builder().build(); - Task shutdownVapp = vAppApi.undeploy(test.getHref(), undeployParams); + Task shutdownVapp = vAppApi.undeploy(vmUrn, undeployParams); assertTaskSucceedsLong(shutdownVapp); } - test = vmApi.get(testVmURI); + test = vmApi.get(vmUrn); assertStatus(VM, test, Status.POWERED_OFF); return test; } @@ -309,14 +309,14 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT /** * Suspend a {@link VApp}. */ - protected VApp suspendVApp(final URI testVAppURI) { - VApp test = vAppApi.getVApp(testVAppURI); + protected VApp suspendVApp(String vAppUrn) { + VApp test = vAppApi.get(vAppUrn); Status status = test.getStatus(); if (status != Status.SUSPENDED) { - Task suspend = vAppApi.suspend(vm.getHref()); + Task suspend = vAppApi.suspend(vAppUrn); assertTaskSucceedsLong(suspend); } - test = vAppApi.getVApp(testVAppURI); + test = vAppApi.get(vAppUrn); assertStatus(VAPP, test, Status.SUSPENDED); return test; } @@ -324,14 +324,14 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT /** * Suspend a {@link Vm}. */ - protected Vm suspendVm(final URI testVmURI) { - Vm test = vmApi.get(testVmURI); + protected Vm suspendVm(String vmUrn) { + Vm test = vmApi.get(vmUrn); Status status = test.getStatus(); if (status != Status.SUSPENDED) { - Task suspend = vmApi.suspend(vm.getHref()); + Task suspend = vmApi.suspend(vmUrn); assertTaskSucceedsLong(suspend); } - test = vmApi.get(testVmURI); + test = vmApi.get(vmUrn); assertStatus(VM, test, Status.SUSPENDED); return test; } @@ -339,16 +339,16 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT /** * Check the {@link VApp}s current status. */ - protected void assertVAppStatus(final URI testVAppURI, final Status status) { - VApp testVApp = vAppApi.getVApp(testVAppURI); + protected void assertVAppStatus(final String vAppUrn, final Status status) { + VApp testVApp = vAppApi.get(vAppUrn); assertStatus(VAPP, testVApp, status); } /** * Check the {@link Vm}s current status. */ - protected void assertVmStatus(final URI testVmURI, final Status status) { - Vm testVm = vmApi.get(testVmURI); + protected void assertVmStatus(String vmUrn, final Status status) { + Vm testVm = vmApi.get(vmUrn); assertStatus(VM, testVm, status); } @@ -376,7 +376,7 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT } protected VAppNetworkConfiguration getVAppNetworkConfig(VApp vApp) { - Set vAppNetworkConfigs = vAppApi.getNetworkConfigSection(vApp.getHref()).getNetworkConfigs(); + Set vAppNetworkConfigs = vAppApi.getNetworkConfigSection(vApp.getId()).getNetworkConfigs(); return Iterables.tryFind(vAppNetworkConfigs, Predicates.notNull()).orNull(); } @@ -389,11 +389,11 @@ public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveT } protected Set listNetworkConnections(Vm vm) { - return vmApi.getNetworkConnectionSection(vm.getHref()).getNetworkConnections(); + return vmApi.getNetworkConnectionSection(vm.getId()).getNetworkConnections(); } protected Set listVappNetworkConfigurations(VApp vApp) { - Set vAppNetworkConfigs = vAppApi.getNetworkConfigSection(vApp.getHref()).getNetworkConfigs(); + Set vAppNetworkConfigs = vAppApi.getNetworkConfigSection(vApp.getId()).getNetworkConfigs(); return vAppNetworkConfigs; } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogApiExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogApiExpectTest.java index a496896922..365a90c45e 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogApiExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogApiExpectTest.java @@ -151,7 +151,7 @@ public class CatalogApiExpectTest extends VCloudDirectorApiExpectTest { @Test public void testGetCatalogMetadataHref() { VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getMetadata, getMetadataResponse); - assertEquals(api.getCatalogApi().getMetadataApi().get(catalogHref), metadata()); + assertEquals(api.getCatalogApi().getMetadataApi(catalogHref).get(), metadata()); } static Metadata metadata() { @@ -182,7 +182,7 @@ public class CatalogApiExpectTest extends VCloudDirectorApiExpectTest { @Test public void testGetCatalogMetadataEntryHref() { VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getMetadataValue, getMetadataValueResponse); - assertEquals(api.getCatalogApi().getMetadataApi().getValue(catalogHref, "KEY"), metadataValue()); + assertEquals(api.getCatalogApi().getMetadataApi(catalogHref).getValue("KEY"), metadataValue()); } static String item = "a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df"; @@ -308,7 +308,7 @@ public class CatalogApiExpectTest extends VCloudDirectorApiExpectTest { @Test public void testGetCatalogItemMetadataHref() { VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getItemMetadata, getItemMetadataResponse); - assertEquals(api.getCatalogApi().getMetadataApi().get(itemHref), expected); + assertEquals(api.getCatalogApi().getMetadataApi(itemHref).get(), expected); } HttpRequest mergeItemMetadata = HttpRequest.builder() @@ -330,7 +330,7 @@ public class CatalogApiExpectTest extends VCloudDirectorApiExpectTest { VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, mergeItemMetadata, mergeItemMetadataResponse); // TODO: horrendous way of representing Map Metadata metadata = Metadata.builder().entry(MetadataEntry.builder().entry("KEY", "VALUE").build()).build(); - assertEquals(api.getCatalogApi().getItemMetadataApi().merge(itemHref, metadata), mergeMetadataTask()); + assertEquals(api.getCatalogApi().getItemMetadataApi(itemHref).merge(metadata), mergeMetadataTask()); } HttpRequest getItemMetadataValue = HttpRequest.builder() @@ -348,7 +348,7 @@ public class CatalogApiExpectTest extends VCloudDirectorApiExpectTest { @Test public void testGetCatalogItemMetadataEntryHref() { VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getItemMetadataValue, getItemMetadataValueResponse); - assertEquals(api.getCatalogApi().getMetadataApi().getValue(itemHref, "KEY"), itemMetadataValue()); + assertEquals(api.getCatalogApi().getMetadataApi(itemHref).getValue("KEY"), itemMetadataValue()); } HttpRequest putItemMetadata = HttpRequest.builder() @@ -368,7 +368,7 @@ public class CatalogApiExpectTest extends VCloudDirectorApiExpectTest { @Test public void testSetCatalogItemMetadataEntryHref() { VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, putItemMetadata, putItemMetadataResponse); - assertEquals(api.getCatalogApi().getItemMetadataApi().putEntry(itemHref, "KEY", MetadataValue.builder().value("KITTENS").build()), setMetadataValueTask()); + assertEquals(api.getCatalogApi().getItemMetadataApi(itemHref).putEntry("KEY", MetadataValue.builder().value("KITTENS").build()), setMetadataValueTask()); } HttpRequest removeItemMetadataEntry = HttpRequest.builder() @@ -386,7 +386,7 @@ public class CatalogApiExpectTest extends VCloudDirectorApiExpectTest { @Test public void testRemoveCatalogItemMetadataEntryHref() { VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, removeItemMetadataEntry, removeItemMetadataEntryResponse); - assertEquals(api.getCatalogApi().getItemMetadataApi().removeEntry(itemHref, "KEY"), removeEntryTask()); + assertEquals(api.getCatalogApi().getItemMetadataApi(itemHref).removeEntry("KEY"), removeEntryTask()); } public static final Catalog catalog() { diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogApiLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogApiLiveTest.java index 2a3aaff278..b4efdca63f 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogApiLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/CatalogApiLiveTest.java @@ -96,7 +96,7 @@ public class CatalogApiLiveTest extends BaseVCloudDirectorApiLiveTest { Metadata newMetadata = Metadata.builder().entry(MetadataEntry.builder().entry("KEY", "MARMALADE").build()) .build(); - Task mergeCatalogMetadata = adminCatalogApi.getMetadataApi().merge(adminCatalog.getHref(), newMetadata); + Task mergeCatalogMetadata = adminCatalogApi.getMetadataApi(adminCatalog.getId()).merge(newMetadata); checkTask(mergeCatalogMetadata); assertTrue(retryTaskSuccess.apply(mergeCatalogMetadata), String.format(TASK_COMPLETE_TIMELY, "setupRequiredApis")); @@ -184,13 +184,13 @@ public class CatalogApiLiveTest extends BaseVCloudDirectorApiLiveTest { @Test(description = "GET /catalog/{id}/metadata") public void testGetCatalogMetadata() { - Metadata catalogMetadata = catalogApi.getMetadataApi().get(lazyGetCatalog().getHref()); + Metadata catalogMetadata = catalogApi.getMetadataApi(catalogUrn).get(); checkMetadata(catalogMetadata); } @Test(description = "GET /catalog/{id}/metadata/{key}") public void testGetCatalogMetadataValue() { - Metadata catalogMetadata = catalogApi.getMetadataApi().get(lazyGetCatalog().getHref()); + Metadata catalogMetadata = catalogApi.getMetadataApi(catalogUrn).get(); MetadataEntry existingMetadataEntry = Iterables.find(catalogMetadata.getMetadataEntries(), new Predicate() { @Override @@ -198,7 +198,8 @@ public class CatalogApiLiveTest extends BaseVCloudDirectorApiLiveTest { return input.getKey().equals("KEY"); } }); - MetadataValue metadataValue = catalogApi.getMetadataApi().getValue(existingMetadataEntry.getHref(), "KEY"); + MetadataValue metadataValue = catalogApi.getMetadataApi(catalogApi.get(existingMetadataEntry.getHref()).getId()) + .getValue("KEY"); assertEquals(metadataValue.getValue(), existingMetadataEntry.getValue(), String.format(CORRECT_VALUE_OBJECT_FMT, "Value", "MetadataValue", existingMetadataEntry.getValue(), metadataValue.getValue())); checkMetadataValue(metadataValue); @@ -206,7 +207,7 @@ public class CatalogApiLiveTest extends BaseVCloudDirectorApiLiveTest { @Test(description = "GET /catalogItem/{id}/metadata", dependsOnMethods = "testAddCatalogItem") public void testGetCatalogItemMetadata() { - Metadata catalogItemMetadata = catalogApi.getItemMetadataApi().get(catalogItem.getHref()); + Metadata catalogItemMetadata = catalogApi.getItemMetadataApi(catalogItem.getId()).get(); checkMetadata(catalogItemMetadata); } @@ -215,23 +216,23 @@ public class CatalogApiLiveTest extends BaseVCloudDirectorApiLiveTest { Metadata newMetadata = Metadata.builder().entry(MetadataEntry.builder().entry("KEY", "MARMALADE").build()) .entry(MetadataEntry.builder().entry("VEGIMITE", "VALUE").build()).build(); - Metadata before = catalogApi.getItemMetadataApi().get(catalogItem.getHref()); + Metadata before = catalogApi.getItemMetadataApi(catalogItem.getId()).get(); - Task mergeCatalogItemMetadata = catalogApi.getItemMetadataApi().merge(catalogItem.getHref(), newMetadata); + Task mergeCatalogItemMetadata = catalogApi.getItemMetadataApi(catalogItem.getId()).merge(newMetadata); checkTask(mergeCatalogItemMetadata); assertTrue(retryTaskSuccess.apply(mergeCatalogItemMetadata), String.format(TASK_COMPLETE_TIMELY, "mergeCatalogItemMetadata")); - Metadata mergedCatalogItemMetadata = catalogApi.getItemMetadataApi().get(catalogItem.getHref()); + Metadata mergedCatalogItemMetadata = catalogApi.getItemMetadataApi(catalogItem.getId()).get(); assertTrue(mergedCatalogItemMetadata.getMetadataEntries().size() > before.getMetadataEntries().size(), "Should have added at least one other MetadataEntry to the CatalogItem"); - MetadataValue keyMetadataValue = catalogApi.getItemMetadataApi().getValue(catalogItem.getHref(), "KEY"); + MetadataValue keyMetadataValue = catalogApi.getItemMetadataApi(catalogItem.getId()).getValue("KEY"); assertEquals(keyMetadataValue.getValue(), "MARMALADE", "The Value of the MetadataValue for KEY should have changed"); checkMetadataValue(keyMetadataValue); - MetadataValue newKeyMetadataValue = catalogApi.getItemMetadataApi().getValue(catalogItem.getHref(), "VEGIMITE"); + MetadataValue newKeyMetadataValue = catalogApi.getItemMetadataApi(catalogItem.getId()).getValue("VEGIMITE"); assertEquals(newKeyMetadataValue.getValue(), "VALUE", "The Value of the MetadataValue for NEW_KEY should have been set"); @@ -240,7 +241,7 @@ public class CatalogApiLiveTest extends BaseVCloudDirectorApiLiveTest { @Test(description = "GET /catalogItem/{id}/metadata/{key}", dependsOnMethods = "testSetCatalogItemMetadataValue") public void testGetCatalogItemMetadataValue() { - MetadataValue metadataValue = catalogApi.getItemMetadataApi().getValue(catalogItem.getHref(), "KEY"); + MetadataValue metadataValue = catalogApi.getItemMetadataApi(catalogItem.getId()).getValue("KEY"); checkMetadataValue(metadataValue); } @@ -248,26 +249,25 @@ public class CatalogApiLiveTest extends BaseVCloudDirectorApiLiveTest { public void testSetCatalogItemMetadataValue() { MetadataValue newMetadataValue = MetadataValue.builder().value("NEW").build(); - Task setCatalogItemMetadataValue = catalogApi.getItemMetadataApi().putEntry(catalogItem.getHref(), "KEY", + Task setCatalogItemMetadataValue = catalogApi.getItemMetadataApi(catalogItem.getId()).putEntry("KEY", newMetadataValue); checkTask(setCatalogItemMetadataValue); assertTrue(retryTaskSuccess.apply(setCatalogItemMetadataValue), String.format(TASK_COMPLETE_TIMELY, "setCatalogItemMetadataValue")); - MetadataValue editedMetadataValue = catalogApi.getItemMetadataApi().getValue(catalogItem.getHref(), "KEY"); - assertEquals(editedMetadataValue.getValue(), newMetadataValue.getValue(), String.format( - CORRECT_VALUE_OBJECT_FMT, "Value", "MetadataValue", newMetadataValue.getValue(), - editedMetadataValue.getValue())); + MetadataValue editedMetadataValue = catalogApi.getItemMetadataApi(catalogItem.getId()).getValue("KEY"); + assertEquals(editedMetadataValue.getValue(), newMetadataValue.getValue(), String.format(CORRECT_VALUE_OBJECT_FMT, + "Value", "MetadataValue", newMetadataValue.getValue(), editedMetadataValue.getValue())); checkMetadataValue(editedMetadataValue); } @Test(description = "DELETE /catalogItem/{id}/metadata/{key}", dependsOnMethods = "testGetCatalogItemMetadataValue") public void testRemoveCatalogItemMetadataValue() { - Task removeCatalogItemMetadataValue = catalogApi.getItemMetadataApi().removeEntry(catalogItem.getHref(), "KEY"); + Task removeCatalogItemMetadataValue = catalogApi.getItemMetadataApi(catalogItem.getId()).removeEntry("KEY"); checkTask(removeCatalogItemMetadataValue); assertTrue(retryTaskSuccess.apply(removeCatalogItemMetadataValue), String.format(TASK_COMPLETE_TIMELY, "removeCatalogItemMetadataValue")); - MetadataValue removed = catalogApi.getMetadataApi().getValue(catalogItem.getHref(), "KEY"); + MetadataValue removed = catalogApi.getItemMetadataApi(catalogItem.getId()).getValue("KEY"); assertNull(removed); } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaApiExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaApiExpectTest.java index 3847a66a50..ea9e163b88 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaApiExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaApiExpectTest.java @@ -239,7 +239,7 @@ public class MediaApiExpectTest extends VCloudDirectorAdminApiExpectTest { Metadata expected = metadata(); - assertEquals(api.getMediaApi().getMetadataApi().get(mediaUri), expected); + assertEquals(api.getMediaApi().getMetadataApi(mediaUri).get(), expected); } @Test @@ -259,7 +259,7 @@ public class MediaApiExpectTest extends VCloudDirectorAdminApiExpectTest { Metadata inputMetadata = metadata(); Task expectedTask = mergeMetadataTask(); - assertEquals(api.getMediaApi().getMetadataApi().merge(mediaUri, inputMetadata), expectedTask); + assertEquals(api.getMediaApi().getMetadataApi(mediaUri).merge(inputMetadata), expectedTask); } public void testGetMetadataValue() { @@ -277,7 +277,7 @@ public class MediaApiExpectTest extends VCloudDirectorAdminApiExpectTest { MetadataValue expected = metadataValue(); - assertEquals(api.getMediaApi().getMetadataApi().getValue(mediaUri, "key"), expected); + assertEquals(api.getMediaApi().getMetadataApi(mediaUri).getValue("key"), expected); } @Test @@ -298,7 +298,7 @@ public class MediaApiExpectTest extends VCloudDirectorAdminApiExpectTest { Task expectedTask = setMetadataEntryTask(); - assertEquals(api.getMediaApi().getMetadataApi().putEntry(mediaUri, "key", inputMetadataValue), expectedTask); + assertEquals(api.getMediaApi().getMetadataApi(mediaUri).putEntry("key", inputMetadataValue), expectedTask); } @Test @@ -316,7 +316,7 @@ public class MediaApiExpectTest extends VCloudDirectorAdminApiExpectTest { Task expectedTask = removeEntryTask(); - assertEquals(api.getMediaApi().getMetadataApi().removeEntry(mediaUri, "key"), expectedTask); + assertEquals(api.getMediaApi().getMetadataApi(mediaUri).removeEntry("key"), expectedTask); } @Test diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaApiLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaApiLiveTest.java index cb97da31dc..9e4b814045 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaApiLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/MediaApiLiveTest.java @@ -88,7 +88,7 @@ public class MediaApiLiveTest extends BaseVCloudDirectorApiLiveTest { */ protected VdcApi vdcApi; protected MediaApi mediaApi; - + /* * Shared state between dependent tests. */ @@ -104,63 +104,64 @@ public class MediaApiLiveTest extends BaseVCloudDirectorApiLiveTest { vdcApi = context.getApi().getVdcApi(); mediaApi = context.getApi().getMediaApi(); } - + @AfterClass(alwaysRun = true) protected void tidyUp() { if (media != null) { try { - Task remove = mediaApi.removeMedia(media.getHref()); - taskDoneEventually(remove); + Task remove = mediaApi.removeMedia(media.getHref()); + taskDoneEventually(remove); } catch (Exception e) { logger.warn(e, "Error when deleting media '%s': %s", media.getName()); } } if (oldMedia != null) { try { - Task remove = mediaApi.removeMedia(oldMedia.getHref()); - taskDoneEventually(remove); + Task remove = mediaApi.removeMedia(oldMedia.getHref()); + taskDoneEventually(remove); } catch (Exception e) { logger.warn(e, "Error when deleting media '%s': %s", oldMedia.getName()); } } } - + @Test(description = "POST /vdc/{id}/media") public void testAddMedia() throws URISyntaxException { - Vdc vdc = lazyGetVdc(); + Vdc vdc = lazyGetVdc(); Link addMedia = find(vdc.getLinks(), and(relEquals("add"), typeEquals(VCloudDirectorMediaType.MEDIA))); - + // TODO: generate an iso byte[] iso = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; - - Media sourceMedia = Media.builder() - .type(VCloudDirectorMediaType.MEDIA) - .name("Test media "+random.nextInt()) - .size(iso.length) - .imageType(Media.ImageType.ISO) - .description("Test media generated by testAddMedia()") - .build(); + + Media sourceMedia = Media.builder().type(VCloudDirectorMediaType.MEDIA).name("Test media " + random.nextInt()) + .size(iso.length).imageType(Media.ImageType.ISO).description("Test media generated by testAddMedia()") + .build(); media = mediaApi.addMedia(addMedia.getHref(), sourceMedia); - + Checks.checkMediaFor(MEDIA, media); - + assertNotNull(media.getFiles(), String.format(OBJ_FIELD_REQ, MEDIA, "files")); - assertTrue(media.getFiles().size() == 1, String.format(OBJ_FIELD_LIST_SIZE_EQ, MEDIA, "files", 1, media.getFiles().size())); + assertTrue(media.getFiles().size() == 1, + String.format(OBJ_FIELD_LIST_SIZE_EQ, MEDIA, "files", 1, media.getFiles().size())); File uploadFile = getFirst(media.getFiles(), null); assertNotNull(uploadFile, String.format(OBJ_FIELD_REQ, MEDIA, "files.first")); assertEquals(uploadFile.getSize(), Long.valueOf(iso.length)); assertEquals(uploadFile.getSize().longValue(), sourceMedia.getSize(), - String.format(OBJ_FIELD_EQ, MEDIA, "uploadFile.size()", sourceMedia.getSize(), uploadFile.getSize())); - + String.format(OBJ_FIELD_EQ, MEDIA, "uploadFile.size()", sourceMedia.getSize(), uploadFile.getSize())); + Set links = uploadFile.getLinks(); assertNotNull(links, String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links")); assertTrue(links.size() >= 1, String.format(OBJ_FIELD_LIST_SIZE_GE, MEDIA, "uploadfile.links", 1, links.size())); - assertTrue(Iterables.all(links, Predicates.or(LinkPredicates.relEquals(Link.Rel.UPLOAD_DEFAULT), LinkPredicates.relEquals(Link.Rel.UPLOAD_ALTERNATE))), - String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links.first")); + assertTrue( + Iterables.all( + links, + Predicates.or(LinkPredicates.relEquals(Link.Rel.UPLOAD_DEFAULT), + LinkPredicates.relEquals(Link.Rel.UPLOAD_ALTERNATE))), + String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links.first")); Link uploadLink = Iterables.find(links, LinkPredicates.relEquals(Link.Rel.UPLOAD_DEFAULT)); context.getApi().getUploadApi().upload(uploadLink.getHref(), Payloads.newByteArrayPayload(iso)); - + media = mediaApi.getMedia(media.getHref()); if (media.getTasks().size() == 1) { Task uploadTask = Iterables.getOnlyElement(media.getTasks()); @@ -170,48 +171,45 @@ public class MediaApiLiveTest extends BaseVCloudDirectorApiLiveTest { media = mediaApi.getMedia(media.getHref()); } } - + @Test(description = "GET /media/{id}", dependsOnMethods = { "testAddMedia" }) public void testGetMedia() { media = mediaApi.getMedia(media.getHref()); assertNotNull(media, String.format(OBJ_REQ_LIVE, MEDIA)); - + owner = media.getOwner(); assertNotNull(owner, String.format(OBJ_FIELD_REQ_LIVE, MEDIA, "owner")); Checks.checkResourceType(media.getOwner()); - + Checks.checkMediaFor(MEDIA, media); } - + @Test(description = "GET /media/{id}/owner", dependsOnMethods = { "testGetMedia" }) public void testGetMediaOwner() { Owner directOwner = mediaApi.getOwner(media.getHref()); - assertEquals(owner.toBuilder() - .user(owner.getUser()) - .build(), - directOwner.toBuilder().links(Collections.emptySet()).build(), - String.format(GETTER_RETURNS_SAME_OBJ, - "getOwner()", "owner", "media.getOwner()", owner.toString(), directOwner.toString())); - + assertEquals(owner.toBuilder().user(owner.getUser()).build(), + directOwner.toBuilder().links(Collections. emptySet()).build(), String.format( + GETTER_RETURNS_SAME_OBJ, "getOwner()", "owner", "media.getOwner()", owner.toString(), + directOwner.toString())); + // parent type Checks.checkResourceType(directOwner); - + // required assertNotNull(directOwner.getUser(), String.format(OBJ_FIELD_REQ, "Owner", "user")); Checks.checkReferenceType(directOwner.getUser()); } - + @Test(description = "POST /vdc/{id}/action/cloneMedia", dependsOnMethods = { "testGetMediaOwner" }) public void testCloneMedia() { oldMedia = media; - media = vdcApi.cloneMedia(vdcUrn, CloneMediaParams.builder() - .source(Reference.builder().fromEntity(media).build()) - .name("copied "+media.getName()) - .description("copied by testCloneMedia()") - .build()); - + media = vdcApi.cloneMedia( + vdcUrn, + CloneMediaParams.builder().source(Reference.builder().fromEntity(media).build()) + .name("copied " + media.getName()).description("copied by testCloneMedia()").build()); + Checks.checkMediaFor(VDC, media); - + if (media.getTasks() != null) { Task copyTask = getFirst(media.getTasks(), null); if (copyTask != null) { @@ -220,22 +218,19 @@ public class MediaApiLiveTest extends BaseVCloudDirectorApiLiveTest { media = mediaApi.getMedia(media.getHref()); } } - + Checks.checkMediaFor(MEDIA, media); - assertTrue(media.clone(oldMedia), String.format(OBJ_FIELD_CLONE, MEDIA, "copied media", - media.toString(), oldMedia.toString())); - - mediaApi.getMetadataApi().putEntry(media.getHref(), "key", MetadataValue.builder().value("value").build()); - - media = vdcApi.cloneMedia(vdcUrn, CloneMediaParams.builder() - .source(Reference.builder().fromEntity(media).build()) - .name("moved test media") - .description("moved by testCloneMedia()") - .isSourceDelete(true) - .build()); - + assertTrue(media.clone(oldMedia), + String.format(OBJ_FIELD_CLONE, MEDIA, "copied media", media.toString(), oldMedia.toString())); + + mediaApi.getMetadataApi(media.getId()).putEntry("key", MetadataValue.builder().value("value").build()); + + media = vdcApi + .cloneMedia(vdcUrn, CloneMediaParams.builder().source(Reference.builder().fromEntity(media).build()) + .name("moved test media").description("moved by testCloneMedia()").isSourceDelete(true).build()); + Checks.checkMediaFor(VDC, media); - + if (media.getTasks() != null) { Task copyTask = getFirst(media.getTasks(), null); if (copyTask != null) { @@ -244,151 +239,144 @@ public class MediaApiLiveTest extends BaseVCloudDirectorApiLiveTest { media = mediaApi.getMedia(media.getHref()); } } - + Checks.checkMediaFor(MEDIA, media); - assertTrue(media.clone(oldMedia), String.format(OBJ_FIELD_CLONE, MEDIA, "moved media", - media.toString(), oldMedia.toString())); + assertTrue(media.clone(oldMedia), + String.format(OBJ_FIELD_CLONE, MEDIA, "moved media", media.toString(), oldMedia.toString())); } - + @Test(description = "PUT /media/{id}", dependsOnMethods = { "testCloneMedia" }) public void testSetMedia() { String oldName = media.getName(); - String newName = "new "+oldName; + String newName = "new " + oldName; String oldDescription = media.getDescription(); - String newDescription = "new "+oldDescription; + String newDescription = "new " + oldDescription; media = media.toBuilder().name(newName).description(newDescription).build(); - + Task editMedia = mediaApi.editMedia(media.getHref(), media); Checks.checkTask(editMedia); assertTrue(retryTaskSuccess.apply(editMedia), String.format(TASK_COMPLETE_TIMELY, "editMedia")); media = mediaApi.getMedia(media.getHref()); - + assertTrue(equal(media.getName(), newName), String.format(OBJ_FIELD_UPDATABLE, MEDIA, "name")); assertTrue(equal(media.getDescription(), newDescription), - String.format(OBJ_FIELD_UPDATABLE, MEDIA, "description")); - - //TODO negative tests? - + String.format(OBJ_FIELD_UPDATABLE, MEDIA, "description")); + + // TODO negative tests? + Checks.checkMediaFor(MEDIA, media); - + media = media.toBuilder().name(oldName).description(oldDescription).build(); - + editMedia = mediaApi.editMedia(media.getHref(), media); Checks.checkTask(editMedia); assertTrue(retryTaskSuccess.apply(editMedia), String.format(TASK_COMPLETE_TIMELY, "editMedia")); media = mediaApi.getMedia(media.getHref()); } - + @Test(description = "GET /media/{id}/metadata", dependsOnMethods = { "testSetMetadataValue" }) public void testGetMetadata() { - metadata = mediaApi.getMetadataApi().get(media.getHref()); + metadata = mediaApi.getMetadataApi(media.getId()).get(); // required for testing - assertFalse(isEmpty(metadata.getMetadataEntries()), - String.format(OBJ_FIELD_REQ_LIVE, MEDIA, "metadata.entries")); - + assertFalse(isEmpty(metadata.getMetadataEntries()), String.format(OBJ_FIELD_REQ_LIVE, MEDIA, "metadata.entries")); + Checks.checkMetadataFor(MEDIA, metadata); } - + @Test(description = "POST /media/{id}/metadata", dependsOnMethods = { "testGetMedia" }) public void testMergeMetadata() { // test new Set inputEntries = ImmutableSet.of(MetadataEntry.builder().entry("testKey", "testValue").build()); - Metadata inputMetadata = Metadata.builder() - .entries(inputEntries) - .build(); - - Task mergeMetadata = mediaApi.getMetadataApi().merge(media.getHref(), inputMetadata); + Metadata inputMetadata = Metadata.builder().entries(inputEntries).build(); + + Task mergeMetadata = mediaApi.getMetadataApi(media.getId()).merge(inputMetadata); Checks.checkTask(mergeMetadata); assertTrue(retryTaskSuccess.apply(mergeMetadata), String.format(TASK_COMPLETE_TIMELY, "mergeMetadata(new)")); - metadata = mediaApi.getMetadataApi().get(media.getHref()); + metadata = mediaApi.getMetadataApi(media.getId()).get(); Checks.checkMetadataFor(MEDIA, metadata); checkMetadataContainsEntries(metadata, inputEntries); - + media = mediaApi.getMedia(media.getHref()); Checks.checkMediaFor(MEDIA, media); - + // test edit inputEntries = ImmutableSet.of(MetadataEntry.builder().entry("testKey", "new testValue").build()); - inputMetadata = Metadata.builder() - .entries(inputEntries) - .build(); - - mergeMetadata = mediaApi.getMetadataApi().merge(media.getHref(), inputMetadata); + inputMetadata = Metadata.builder().entries(inputEntries).build(); + + mergeMetadata = mediaApi.getMetadataApi(media.getId()).merge(inputMetadata); Checks.checkTask(mergeMetadata); assertTrue(retryTaskSuccess.apply(mergeMetadata), String.format(TASK_COMPLETE_TIMELY, "mergeMetadata(edit)")); - metadata = mediaApi.getMetadataApi().get(media.getHref()); + metadata = mediaApi.getMetadataApi(media.getId()).get(); Checks.checkMetadataFor(MEDIA, metadata); checkMetadataContainsEntries(metadata, inputEntries); - + media = mediaApi.getMedia(media.getHref()); Checks.checkMediaFor(MEDIA, media); } - + private void checkMetadataContainsEntries(Metadata metadata, Set entries) { for (MetadataEntry inputEntry : entries) { boolean found = false; for (MetadataEntry entry : metadata.getMetadataEntries()) { if (equal(inputEntry.getKey(), entry.getKey())) { - found = true; break; + found = true; + break; } } - + if (!found) { - String.format(OBJ_FIELD_CONTAINS, MEDIA, "metadata", - Iterables.toString(metadata.getMetadataEntries()), - Iterables.toString(entries)); + String.format(OBJ_FIELD_CONTAINS, MEDIA, "metadata", Iterables.toString(metadata.getMetadataEntries()), + Iterables.toString(entries)); } } } - + @Test(description = "GET /media/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadataValue" }) public void testGetMetadataValue() { - metadataValue = mediaApi.getMetadataApi().getValue(media.getHref(), "key"); + metadataValue = mediaApi.getMetadataApi(media.getId()).getValue("key"); Checks.checkMetadataValueFor(MEDIA, metadataValue); } - + @Test(description = "PUT /media/{id}/metadata/{key}", dependsOnMethods = { "testMergeMetadata" }) public void testSetMetadataValue() { metadataEntryValue = "value"; MetadataValue newValue = MetadataValue.builder().value(metadataEntryValue).build(); - - Task setMetadataEntry = mediaApi.getMetadataApi().putEntry(media.getHref(), "key", newValue); + + Task setMetadataEntry = mediaApi.getMetadataApi(media.getId()).putEntry("key", newValue); Checks.checkTask(setMetadataEntry); - assertTrue(retryTaskSuccess.apply(setMetadataEntry), - String.format(TASK_COMPLETE_TIMELY, "setMetadataEntry")); - metadataValue = mediaApi.getMetadataApi().getValue(media.getHref(), "key"); + assertTrue(retryTaskSuccess.apply(setMetadataEntry), String.format(TASK_COMPLETE_TIMELY, "setMetadataEntry")); + metadataValue = mediaApi.getMetadataApi(media.getId()).getValue("key"); Checks.checkMetadataValueFor(MEDIA, metadataValue); } - - @Test(description = "DELETE /media/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadata", "testGetMetadataValue" } ) + + @Test(description = "DELETE /media/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadata", + "testGetMetadataValue" }) public void testRemoveMetadata() { - Task removeEntry = mediaApi.getMetadataApi().removeEntry(media.getHref(), "testKey"); + Task removeEntry = mediaApi.getMetadataApi(media.getId()).removeEntry("testKey"); Checks.checkTask(removeEntry); - assertTrue(retryTaskSuccess.apply(removeEntry), - String.format(TASK_COMPLETE_TIMELY, "removeEntry")); - - metadataValue = mediaApi.getMetadataApi().getValue(media.getHref(), "testKey"); - assertNull(metadataValue, String.format(OBJ_FIELD_ATTRB_DEL, MEDIA, - "Metadata", metadataValue != null ? metadataValue.toString() : "", - "MetadataEntry", metadataValue != null ? metadataValue.toString() : "")); - - metadataValue = mediaApi.getMetadataApi().getValue(media.getHref(), "key"); + assertTrue(retryTaskSuccess.apply(removeEntry), String.format(TASK_COMPLETE_TIMELY, "removeEntry")); + + metadataValue = mediaApi.getMetadataApi(media.getId()).getValue("testKey"); + assertNull(metadataValue, String.format(OBJ_FIELD_ATTRB_DEL, MEDIA, "Metadata", + metadataValue != null ? metadataValue.toString() : "", "MetadataEntry", + metadataValue != null ? metadataValue.toString() : "")); + + metadataValue = mediaApi.getMetadataApi(media.getId()).getValue("key"); Checks.checkMetadataValueFor(MEDIA, metadataValue); - + media = mediaApi.getMedia(media.getHref()); Checks.checkMediaFor(MEDIA, media); } - - @Test(description = "DELETE /media/{id}", dependsOnMethods = { "testRemoveMetadata" } ) + + @Test(description = "DELETE /media/{id}", dependsOnMethods = { "testRemoveMetadata" }) public void testRemoveMedia() { Task removeMedia = mediaApi.removeMedia(media.getHref()); Checks.checkTask(removeMedia); - assertTrue(retryTaskSuccess.apply(removeMedia), - String.format(TASK_COMPLETE_TIMELY, "removeMedia")); - + assertTrue(retryTaskSuccess.apply(removeMedia), String.format(TASK_COMPLETE_TIMELY, "removeMedia")); + media = mediaApi.getMedia(media.getHref()); assertNull(media, String.format(OBJ_DEL, MEDIA, media != null ? media.toString() : "")); - + removeMedia = mediaApi.removeMedia(oldMedia.getHref()); Checks.checkTask(removeMedia); assertTrue(retryTaskSuccess.apply(removeMedia), String.format(TASK_COMPLETE_TIMELY, "removeMedia")); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkApiExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkApiExpectTest.java index b26d47a744..5458c81c5b 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkApiExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkApiExpectTest.java @@ -181,7 +181,7 @@ public class NetworkApiExpectTest extends VCloudDirectorAdminApiExpectTest { @Test public void testGetNetworkMetadataHref() { VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getMetadata, getMetadataResponse); - assertEquals(api.getNetworkApi().getMetadataApi().get(networkHref), metadata()); + assertEquals(api.getNetworkApi().getMetadataApi(networkHref).get(), metadata()); } static Metadata metadata() { @@ -216,7 +216,7 @@ public class NetworkApiExpectTest extends VCloudDirectorAdminApiExpectTest { @Test public void testGetNetworkMetadataEntryHref() { VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getMetadataValue, getMetadataValueResponse); - assertEquals(api.getNetworkApi().getMetadataApi().getValue(networkHref, "KEY"), metadataValue()); + assertEquals(api.getNetworkApi().getMetadataApi(networkHref).getValue("KEY"), metadataValue()); } private MetadataValue metadataValue() { diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkApiLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkApiLiveTest.java index 4ee729413f..40dc0f0ba2 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkApiLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/NetworkApiLiveTest.java @@ -22,8 +22,8 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.O import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_EQ; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_REQ_LIVE; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_REQ_LIVE; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.URN_REQ_LIVE; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REQUIRED_VALUE_OBJECT_FMT; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.URN_REQ_LIVE; import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkResourceType; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; @@ -51,96 +51,92 @@ import com.google.common.collect.Iterables; */ @Test(groups = { "live", "user" }, singleThreaded = true, testName = "NetworkApiLiveTest") public class NetworkApiLiveTest extends BaseVCloudDirectorApiLiveTest { - + public static final String NETWORK = "network"; - + /* * Convenience reference to API api. */ protected NetworkApi networkApi; - + private boolean metadataSet = false; - private Network network; - + @Override @BeforeClass(alwaysRun = true) public void setupRequiredApis() { networkApi = context.getApi().getNetworkApi(); - network = lazyGetNetwork(); } - + @AfterClass(alwaysRun = true) public void cleanUp() { if (metadataSet) { try { - Task remove = adminContext.getApi().getNetworkApi().getMetadataApi().removeEntry(network.getHref(), "key"); - taskDoneEventually(remove); + Task remove = adminContext.getApi().getNetworkApi().getMetadataApi(networkUrn).removeEntry("key"); + taskDoneEventually(remove); } catch (Exception e) { logger.warn(e, "Error when deleting metadata"); } } } - + @Test(description = "GET /network/{id}") public void testGetNetwork() { // required for testing assertNotNull(networkUrn, String.format(URN_REQ_LIVE, NETWORK)); - + Network abstractNetwork = networkApi.get(networkUrn); - assertTrue(abstractNetwork instanceof OrgNetwork, String.format(REQUIRED_VALUE_OBJECT_FMT, - ".class", NETWORK, abstractNetwork.getClass(),"OrgNetwork")); + assertTrue(abstractNetwork instanceof OrgNetwork, + String.format(REQUIRED_VALUE_OBJECT_FMT, ".class", NETWORK, abstractNetwork.getClass(), "OrgNetwork")); OrgNetwork network = Network.toSubType(abstractNetwork); assertNotNull(network, String.format(OBJ_REQ_LIVE, NETWORK)); assertTrue(!network.getDescription().equals("DO NOT USE"), "Network isn't to be used for testing"); - + Checks.checkOrgNetwork(network); } - + private void setupMetadata() { - adminContext.getApi().getNetworkApi().getMetadataApi().putEntry(network.getHref(), - "key", MetadataValue.builder().value("value").build()); + adminContext.getApi().getNetworkApi().getMetadataApi(networkUrn) + .putEntry("key", MetadataValue.builder().value("value").build()); metadataSet = true; } - + @Test(description = "GET /network/{id}/metadata", dependsOnMethods = { "testGetNetwork" }) public void testGetMetadata() { if (adminContext != null) { setupMetadata(); } - - Metadata metadata = networkApi.getMetadataApi().get(network.getHref()); + + Metadata metadata = networkApi.getMetadataApi(networkUrn).get(); // required for testing - assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()), - String.format(OBJ_FIELD_REQ_LIVE, NETWORK, "metadata.entries")); - + assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()), + String.format(OBJ_FIELD_REQ_LIVE, NETWORK, "metadata.entries")); + // parent type checkResourceType(metadata); - + for (MetadataEntry entry : metadata.getMetadataEntries()) { // required elements and attributes - assertNotNull(entry.getKey(), - String.format(OBJ_FIELD_ATTRB_REQ, networkApi, "MetadataEntry", entry.getKey(), "key")); - assertNotNull(entry.getValue(), - String.format(OBJ_FIELD_ATTRB_REQ, networkApi, "MetadataEntry", entry.getValue(), "value")); - + assertNotNull(entry.getKey(), + String.format(OBJ_FIELD_ATTRB_REQ, networkApi, "MetadataEntry", entry.getKey(), "key")); + assertNotNull(entry.getValue(), + String.format(OBJ_FIELD_ATTRB_REQ, networkApi, "MetadataEntry", entry.getValue(), "value")); + // parent type checkResourceType(entry); } } - + @Test(description = "GET /network/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadata" }) public void testGetMetadataValue() { - MetadataValue metadataValue = networkApi.getMetadataApi().getValue(network.getHref(), "key"); - + MetadataValue metadataValue = networkApi.getMetadataApi(networkUrn).getValue("key"); + // Check parent type checkResourceType(metadataValue); - + // Check required elements and attributes String value = metadataValue.getValue(); - assertNotNull(value, - String.format(OBJ_FIELD_ATTRB_REQ, NETWORK, "MetadataEntry", - metadataValue.toString(), "value")); - assertEquals(value, "value", - String.format(OBJ_FIELD_EQ, NETWORK, "metadataEntry.value", "value", value)); + assertNotNull(value, + String.format(OBJ_FIELD_ATTRB_REQ, NETWORK, "MetadataEntry", metadataValue.toString(), "value")); + assertEquals(value, "value", String.format(OBJ_FIELD_EQ, NETWORK, "metadataEntry.value", "value", value)); } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgApiExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgApiExpectTest.java index 98f2a29b91..06c672766d 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgApiExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgApiExpectTest.java @@ -148,7 +148,7 @@ public class OrgApiExpectTest extends VCloudDirectorAdminApiExpectTest { @Test public void testGetOrgMetadataHref() { VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getMetadata, getMetadataResponse); - assertEquals(api.getOrgApi().getMetadataApi().get(orgHref), metadata()); + assertEquals(api.getOrgApi().getMetadataApi(orgHref).get(), metadata()); } static Metadata metadata() { @@ -179,7 +179,7 @@ public class OrgApiExpectTest extends VCloudDirectorAdminApiExpectTest { @Test public void testGetOrgMetadataEntryHref() { VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getMetadataValue, getMetadataValueResponse); - assertEquals(api.getOrgApi().getMetadataApi().getValue(orgHref, "KEY"), metadataValue()); + assertEquals(api.getOrgApi().getMetadataApi(orgHref).getValue("KEY"), metadataValue()); } public static Org org() { diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgApiLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgApiLiveTest.java index d2d7eb2885..050e81431f 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgApiLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgApiLiveTest.java @@ -29,15 +29,12 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; -import java.net.URI; - import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog; 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.Reference; import org.jclouds.vcloud.director.v1_5.domain.Task; -import org.jclouds.vcloud.director.v1_5.domain.org.Org; import org.jclouds.vcloud.director.v1_5.domain.org.OrgList; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorApiLiveTest; import org.testng.annotations.AfterClass; @@ -70,7 +67,7 @@ public class OrgApiLiveTest extends BaseVCloudDirectorApiLiveTest { public void cleanUp() throws Exception { if (adminMembersSet) { try { - Task remove = adminContext.getApi().getOrgApi().getMetadataApi().removeEntry(toAdminUri(orgURI), "KEY"); + Task remove = adminContext.getApi().getOrgApi().getMetadataApi(orgUrn).removeEntry("KEY"); taskDoneEventually(remove); } catch (Exception e) { logger.warn(e, "Error when deleting metadata entry"); @@ -88,8 +85,6 @@ public class OrgApiLiveTest extends BaseVCloudDirectorApiLiveTest { */ private OrgList orgList; - private URI orgURI; - private Org org; private boolean adminMembersSet = false; // track if test entities have been addd @Test(description = "GET /org") @@ -114,12 +109,10 @@ public class OrgApiLiveTest extends BaseVCloudDirectorApiLiveTest { Reference orgRef = Iterables.getFirst(orgList, null); assertNotNull(orgRef); - orgURI = orgRef.getHref(); - // Call the method being tested - org = orgApi.get(orgURI); + org = orgApi.get(orgUrn); - assertEquals(orgApi.get(org.getId()), org); + assertEquals(orgApi.get(orgUrn), org); checkOrg(org); @@ -133,12 +126,12 @@ public class OrgApiLiveTest extends BaseVCloudDirectorApiLiveTest { * the need for configuration */ private void setupAdminMembers() { - adminContext.getApi().getOrgApi().getMetadataApi() - .putEntry(toAdminUri(orgURI), "KEY", MetadataValue.builder().value("VALUE").build()); + adminContext.getApi().getOrgApi().getMetadataApi(orgUrn) + .putEntry("KEY", MetadataValue.builder().value("VALUE").build()); AdminCatalog newCatalog = AdminCatalog.builder().name("Test Catalog " + getTestDateTimeStamp()) .description("created by testOrg()").build(); - newCatalog = adminContext.getApi().getCatalogApi().addCatalogToOrg(newCatalog, org.getId()); + newCatalog = adminContext.getApi().getCatalogApi().addCatalogToOrg(newCatalog, orgUrn); catalogUrn = newCatalog.getId(); @@ -149,7 +142,7 @@ public class OrgApiLiveTest extends BaseVCloudDirectorApiLiveTest { public void testGetOrgMetadata() { // Call the method being tested - Metadata metadata = orgApi.getMetadataApi().get(orgURI); + Metadata metadata = orgApi.getMetadataApi(orgUrn).get(); // NOTE The environment MUST have at one metadata entry for the first organisation configured @@ -163,7 +156,7 @@ public class OrgApiLiveTest extends BaseVCloudDirectorApiLiveTest { @Test(description = "GET /org/{id}/metadata/{key}", dependsOnMethods = { "testGetOrgMetadata" }) public void testGetOrgMetadataValue() { // Call the method being tested - MetadataValue value = orgApi.getMetadataApi().getValue(orgURI, "KEY"); + MetadataValue value = orgApi.getMetadataApi(orgUrn).getValue("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/QueryApiLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryApiLiveTest.java index 1e8cee16c5..efccc3356b 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryApiLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/QueryApiLiveTest.java @@ -52,10 +52,10 @@ import org.testng.annotations.Test; import com.google.common.collect.Iterables; /** -* Tests live behavior of {@link QueryApi}. -* -* @author grkvlt@apache.org -*/ + * Tests live behavior of {@link QueryApi}. + * + * @author grkvlt@apache.org + */ @Test(groups = { "live", "user" }, singleThreaded = true, testName = "QueryApiLiveTest") public class QueryApiLiveTest extends BaseVCloudDirectorApiLiveTest { @@ -64,86 +64,96 @@ public class QueryApiLiveTest extends BaseVCloudDirectorApiLiveTest { */ private QueryApi queryApi; - private VAppTemplateApi vAppTemplateApi; private VAppApi vAppApi; private VApp vApp; - + @AfterClass(alwaysRun = true) public void cleanUp() throws Exception { - if (vApp != null) cleanUpVApp(vApp); + if (vApp != null) + cleanUpVApp(vApp); } @Override @BeforeClass(alwaysRun = true) public void setupRequiredApis() { queryApi = context.getApi().getQueryApi(); - vAppTemplateApi = context.getApi().getVAppTemplateApi(); vAppApi = context.getApi().getVAppApi(); } @Test(description = "GET /query") public void testQuery() { - VAppTemplate vAppTemplate = vAppTemplateApi.getVAppTemplate(vAppTemplateURI); - QueryResultRecords queryResult = queryApi.query("vAppTemplate", String.format("name==%s", vAppTemplate.getName())); + VAppTemplate vAppTemplate = lazyGetVAppTemplate(); + QueryResultRecords queryResult = queryApi + .query("vAppTemplate", String.format("name==%s", vAppTemplate.getName())); Set hrefs = toHrefs(queryResult); - - assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP_TEMPLATE, null), QueryResultVAppTemplateRecord.class); - assertTrue(hrefs.contains(vAppTemplateURI), "VAppTemplates query result should include vAppTemplate "+vAppTemplateURI+"; but only has "+hrefs); + + assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP_TEMPLATE, null), + QueryResultVAppTemplateRecord.class); + assertTrue(hrefs.contains(vAppTemplate.getHref()), "VAppTemplates query result should include vAppTemplate " + + vAppTemplate.getHref() + "; but only has " + hrefs); } @Test(description = "GET /catalogs/query") public void testQueryAllCatalogs() { QueryResultRecords catalogRecords = queryApi.catalogsQueryAll(); - assertFalse(catalogRecords.getRecords().isEmpty(), String.format(NOT_EMPTY_OBJECT_FMT, "CatalogRecord", "QueryResultRecords")); + assertFalse(catalogRecords.getRecords().isEmpty(), + String.format(NOT_EMPTY_OBJECT_FMT, "CatalogRecord", "QueryResultRecords")); } @Test(description = "GET /catalogs/query?format=references", dependsOnMethods = { "testQueryAllCatalogs" }) public void testQueryAllCatalogReferences() { CatalogReferences catalogReferences = queryApi.catalogReferencesQueryAll(); - assertFalse(catalogReferences.getReferences().isEmpty(), String.format(NOT_EMPTY_OBJECT_FMT, "CatalogReference", "CatalogReferences")); + assertFalse(catalogReferences.getReferences().isEmpty(), + String.format(NOT_EMPTY_OBJECT_FMT, "CatalogReference", "CatalogReferences")); } - + @Test(description = "GET /vAppTemplates/query") public void testQueryAllVAppTemplates() { QueryResultRecords queryResult = queryApi.vAppTemplatesQueryAll(); Set hrefs = toHrefs(queryResult); - - assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP_TEMPLATE, null), QueryResultVAppTemplateRecord.class); - assertTrue(hrefs.contains(vAppTemplateURI), "VAppTemplates query result should include vAppTemplate "+vAppTemplateURI+"; but only has "+hrefs); + + assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP_TEMPLATE, null), + QueryResultVAppTemplateRecord.class); + assertTrue(hrefs.contains(lazyGetVAppTemplate().getHref()), "VAppTemplates query result should include vAppTemplate " + + lazyGetVAppTemplate().getHref() + "; but only has " + hrefs); } - + @Test(description = "GET /vAppTemplates/query?filter") public void testQueryVAppTemplatesWithFilter() { - VAppTemplate vAppTemplate = vAppTemplateApi.getVAppTemplate(vAppTemplateURI); + VAppTemplate vAppTemplate = lazyGetVAppTemplate(); QueryResultRecords queryResult = queryApi.vAppTemplatesQuery(String.format("name==%s", vAppTemplate.getName())); Set hrefs = toHrefs(queryResult); - - assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP_TEMPLATE, null), QueryResultVAppTemplateRecord.class); - assertTrue(hrefs.contains(vAppTemplateURI), "VAppTemplates query result should have found vAppTemplate "+vAppTemplateURI); + + assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP_TEMPLATE, null), + QueryResultVAppTemplateRecord.class); + assertTrue(hrefs.contains(vAppTemplate.getHref()), "VAppTemplates query result should have found vAppTemplate " + + vAppTemplate.getHref()); } @Test(description = "GET /vApps/query") public void testQueryAllVApps() { vApp = instantiateVApp(); - + QueryResultRecords queryResult = queryApi.vAppsQueryAll(); Set hrefs = toHrefs(queryResult); - + assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP, null), QueryResultVAppRecord.class); - assertTrue(hrefs.contains(vApp.getHref()), "VApp query result should include vapp "+vApp.getHref()+"; but only has "+hrefs); + assertTrue(hrefs.contains(vApp.getHref()), "VApp query result should include vapp " + vApp.getHref() + + "; but only has " + hrefs); } - - @Test(description = "GET /vApps/query?filter", dependsOnMethods = { "testQueryAllVApps" } ) + + @Test(description = "GET /vApps/query?filter", dependsOnMethods = { "testQueryAllVApps" }) public void testQueryVAppsWithFilter() { QueryResultRecords queryResult = queryApi.vAppsQuery(String.format("name==%s", vApp.getName())); Set hrefs = toHrefs(queryResult); - + assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP, null), QueryResultVAppRecord.class); - assertEquals(hrefs, Collections.singleton(vApp.getHref()), "VApps query result should have found vApp "+vApp.getHref()); + assertEquals(hrefs, Collections.singleton(vApp.getHref()), + "VApps query result should have found vApp " + vApp.getHref()); } - - @Test(description = "GET /vms/query", dependsOnMethods = { "testQueryAllVApps" } ) + + @Test(description = "GET /vms/query", dependsOnMethods = { "testQueryAllVApps" }) public void testQueryAllVms() { // Wait for vApp to have been entirely instantiated Task instantiateTask = Iterables.getFirst(vApp.getTasks(), null); @@ -152,55 +162,60 @@ public class QueryApiLiveTest extends BaseVCloudDirectorApiLiveTest { } // Start the vApp so that it has VMs - Task task = vAppApi.powerOn(vApp.getHref()); + Task task = vAppApi.powerOn(vApp.getId()); assertTaskSucceedsLong(task); - - vApp = vAppApi.getVApp(vApp.getHref()); // reload, so it has the VMs + + vApp = vAppApi.get(vApp.getId()); // reload, so it has the VMs List vms = vApp.getChildren().getVms(); Set vmHrefs = toHrefs(vms); // Method under test: do the query QueryResultRecords queryResult = queryApi.vmsQueryAll(); Set hrefs = toHrefs(queryResult); - + assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VM, null), QueryResultVMRecord.class); - assertTrue(hrefs.containsAll(vmHrefs), "VMs query result should include vms "+vmHrefs+"; but only has "+hrefs); + assertTrue(hrefs.containsAll(vmHrefs), "VMs query result should include vms " + vmHrefs + "; but only has " + + hrefs); } - - @Test(description = "GET /vms/query?filter", dependsOnMethods = { "testQueryAllVms" } ) + + @Test(description = "GET /vms/query?filter", dependsOnMethods = { "testQueryAllVms" }) public void testQueryAllVmsWithFilter() { List vms = vApp.getChildren().getVms(); Set vmHrefs = toHrefs(vms); - + QueryResultRecords queryResult = queryApi.vmsQuery(String.format("containerName==%s", vApp.getName())); Set hrefs = toHrefs(queryResult); - + assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VM, null), QueryResultVMRecord.class); - assertEquals(hrefs, vmHrefs, "VMs query result should equal vms of vApp "+vApp.getName()+" ("+vmHrefs+"); but only has "+hrefs); + assertEquals(hrefs, vmHrefs, "VMs query result should equal vms of vApp " + vApp.getName() + " (" + vmHrefs + + "); but only has " + hrefs); } - + @Test(description = "GET /mediaList/query") public void testQueryAllMedia() { QueryResultRecords queryResult = queryApi.mediaListQueryAll(); - + assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP, null), QueryResultMediaRecord.class); } - + @Test(description = "GET /mediaList/query?filter") public void testQueryMediaWithFilter() { String mediaName = "abc"; QueryResultRecords queryResult = queryApi.mediaListQuery(String.format("name==%s", mediaName)); - + assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP, null), QueryResultMediaRecord.class); } - - private static void assertRecordTypes(QueryResultRecords queryResult, Collection validTypes, Class validClazz) { + + private static void assertRecordTypes(QueryResultRecords queryResult, Collection validTypes, + Class validClazz) { for (QueryResultRecordType record : queryResult.getRecords()) { - assertTrue(validTypes.contains(record.getType()), "invalid type for query result record, "+record.getType()+"; valid types are "+validTypes); - assertEquals(record.getClass(), validClazz, "invalid type for query result record, "+record.getClass()+"; expected "+validClazz); + assertTrue(validTypes.contains(record.getType()), "invalid type for query result record, " + record.getType() + + "; valid types are " + validTypes); + assertEquals(record.getClass(), validClazz, "invalid type for query result record, " + record.getClass() + + "; expected " + validClazz); } } - + private Set toHrefs(QueryResultRecords queryResult) { Set hrefs = new LinkedHashSet(); for (QueryResultRecordType record : queryResult.getRecords()) { @@ -208,7 +223,7 @@ public class QueryApiLiveTest extends BaseVCloudDirectorApiLiveTest { } return hrefs; } - + private Set toHrefs(Iterable resources) { Set hrefs = new LinkedHashSet(); for (Resource resource : resources) { diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppApiExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppApiExpectTest.java index d6f6194327..3f0a62296a 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppApiExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppApiExpectTest.java @@ -82,7 +82,7 @@ public class VAppApiExpectTest extends VCloudDirectorAdminApiExpectTest { VApp expected = getVApp(); - assertEquals(api.getVAppApi().getVApp(vAppURI), expected); + assertEquals(api.getVAppApi().get(vAppURI), expected); } @Test(enabled = false) @@ -103,7 +103,7 @@ public class VAppApiExpectTest extends VCloudDirectorAdminApiExpectTest { Task expected = editVAppTask(); - assertEquals(api.getVAppApi().editVApp(vAppURI, modified), expected); + assertEquals(api.getVAppApi().edit(vAppURI, modified), expected); } @Test(enabled = false) @@ -119,7 +119,7 @@ public class VAppApiExpectTest extends VCloudDirectorAdminApiExpectTest { Task expected = removeVAppTask(); - assertEquals(api.getVAppApi().removeVApp(vAppURI), expected); + assertEquals(api.getVAppApi().remove(vAppURI), expected); } @Test(enabled = false) @@ -349,12 +349,12 @@ public class VAppApiExpectTest extends VCloudDirectorAdminApiExpectTest { .acceptAnyMedia() .httpRequestBuilder().build(), new VcloudHttpResponsePrimer() - .xmlFilePayload("/vApp/getControlAccess.xml", VCloudDirectorMediaType.VAPP) + .xmlFilePayload("/vApp/getAccessControl.xml", VCloudDirectorMediaType.VAPP) .httpResponseBuilder().build()); - ControlAccessParams expected = getControlAccessParams(); + ControlAccessParams expected = getAccessControlParams(); - assertEquals(api.getVAppApi().getControlAccess(vAppURI), expected); + assertEquals(api.getVAppApi().getAccessControl(vAppURI), expected); } @Test(enabled = false) @@ -690,7 +690,7 @@ public class VAppApiExpectTest extends VCloudDirectorAdminApiExpectTest { return task; } - public static ControlAccessParams getControlAccessParams() { + public static ControlAccessParams getAccessControlParams() { ControlAccessParams params = ControlAccessParams.builder() .build(); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppApiLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppApiLiveTest.java index b11850dd6d..8e53db185b 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppApiLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppApiLiveTest.java @@ -183,12 +183,12 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { } /** - * @see VAppApi#getVApp(URI) + * @see VAppApi#get(URI) */ @Test(description = "GET /vApp/{id}") public void testGetVApp() { // The method under test - vApp = vAppApi.getVApp(vAppURI); + vApp = vAppApi.get(vAppUrn); // Check the retrieved object is well formed checkVApp(vApp); @@ -205,7 +205,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { // TODO source.href vAppTemplateURI // Check status - assertVAppStatus(vAppURI, Status.POWERED_OFF); + assertVAppStatus(vAppUrn, Status.POWERED_OFF); } @Test(description = "POST /vApp/{id}/action/recomposeVApp") @@ -220,22 +220,22 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { RecomposeVAppParams params = addRecomposeParams(composedVApp, toAddVm); // The method under test - Task recomposeVApp = vAppApi.recompose(composedVApp.getHref(), params); + Task recomposeVApp = vAppApi.recompose(composedVApp.getId(), params); assertTaskSucceedsLong(recomposeVApp); // add another vm instance to vApp params = addRecomposeParams(composedVApp, toAddVm); - recomposeVApp = vAppApi.recompose(composedVApp.getHref(), params); + recomposeVApp = vAppApi.recompose(composedVApp.getId(), params); assertTaskSucceedsLong(recomposeVApp); // remove a vm - VApp configured = vAppApi.getVApp(composedVApp.getHref()); + VApp configured = vAppApi.get(composedVApp.getId()); List vmsToBeDeleted = configured.getChildren().getVms(); Vm toBeDeleted = Iterables.get(vmsToBeDeleted, 0); - Task removeVm = vmApi.remove(toBeDeleted.getHref()); + Task removeVm = vmApi.remove(toBeDeleted.getId()); assertTaskSucceedsLong(removeVm); - Task removeVApp = vAppApi.removeVApp(composedVApp.getHref()); + Task removeVApp = vAppApi.remove(composedVApp.getId()); assertTaskSucceedsLong(removeVApp); } @@ -243,7 +243,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { Set vms = Sets.newLinkedHashSet(); QueryResultRecords templatesRecords = queryApi.vAppTemplatesQueryAll(); for (QueryResultRecordType templateRecord : templatesRecords.getRecords()) { - VAppTemplate vAppTemplate = vAppTemplateApi.getVAppTemplate(templateRecord.getHref()); + VAppTemplate vAppTemplate = vAppTemplateApi.get(templateRecord.getId()); vms.addAll(vAppTemplate.getChildren()); } return ImmutableSet.copyOf(Iterables.filter(vms, new Predicate() { @@ -251,7 +251,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { // or both. @Override public boolean apply(Vm input) { - GuestCustomizationSection guestCustomizationSection = vmApi.getGuestCustomizationSection(input.getHref()); + GuestCustomizationSection guestCustomizationSection = vmApi.getGuestCustomizationSection(input.getId()); String computerName = guestCustomizationSection.getComputerName(); String retainComputerName = CharMatcher.inRange('0', '9').or(CharMatcher.inRange('a', 'z')) .or(CharMatcher.inRange('A', 'Z')).or(CharMatcher.is('-')).retainFrom(computerName); @@ -261,7 +261,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { } /** - * @see VAppApi#editVApp(URI, VApp) + * @see VAppApi#edit(URI, VApp) */ @Test(description = "PUT /vApp/{id}", dependsOnMethods = { "testGetVApp" }) public void testEditVApp() { @@ -269,11 +269,11 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { vAppNames.add(newVApp.getName()); // The method under test - Task editVApp = vAppApi.editVApp(vApp.getHref(), newVApp); + Task editVApp = vAppApi.edit(vAppUrn, newVApp); assertTrue(retryTaskSuccess.apply(editVApp), String.format(TASK_COMPLETE_TIMELY, "editVApp")); // Get the edited VApp - vApp = vAppApi.getVApp(vApp.getHref()); + vApp = vAppApi.get(vAppUrn); // Check the required fields are set assertEquals(vApp.getName(), newVApp.getName(), @@ -289,139 +289,139 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { .notPowerOn().build(); // The method under test - Task deployVApp = vAppApi.deploy(vApp.getHref(), params); + Task deployVApp = vAppApi.deploy(vAppUrn, params); assertTrue(retryTaskSuccessLong.apply(deployVApp), String.format(TASK_COMPLETE_TIMELY, "deployVApp")); // Get the edited VApp - vApp = vAppApi.getVApp(vApp.getHref()); + vApp = vAppApi.get(vAppUrn); // Check the required fields are set assertTrue(vApp.isDeployed(), String.format(OBJ_FIELD_EQ, VAPP, "deployed", "TRUE", vApp.isDeployed().toString())); // Check status - assertVAppStatus(vAppURI, Status.POWERED_OFF); + assertVAppStatus(vAppUrn, Status.POWERED_OFF); } @Test(description = "POST /vApp/{id}/power/action/powerOn", dependsOnMethods = { "testDeployVApp" }) public void testPowerOnVApp() { // Power off VApp - vApp = powerOffVApp(vApp.getHref()); + vApp = powerOffVApp(vAppUrn); // The method under test - Task powerOnVApp = vAppApi.powerOn(vApp.getHref()); + Task powerOnVApp = vAppApi.powerOn(vAppUrn); assertTaskSucceedsLong(powerOnVApp); // Get the edited VApp - vApp = vAppApi.getVApp(vApp.getHref()); + vApp = vAppApi.get(vAppUrn); // Check status - assertVAppStatus(vAppURI, Status.POWERED_ON); + assertVAppStatus(vAppUrn, Status.POWERED_ON); } @Test(description = "POST /vApp/{id}/power/action/reboot", dependsOnMethods = { "testDeployVApp" }) public void testReboot() { // Power on VApp - vApp = powerOnVApp(vApp.getHref()); + vApp = powerOnVApp(vAppUrn); // The method under test - Task reboot = vAppApi.reboot(vApp.getHref()); + Task reboot = vAppApi.reboot(vAppUrn); assertTaskSucceedsLong(reboot); // Get the edited VApp - vApp = vAppApi.getVApp(vApp.getHref()); + vApp = vAppApi.get(vAppUrn); // Check status - assertVAppStatus(vAppURI, Status.POWERED_OFF); + assertVAppStatus(vAppUrn, Status.POWERED_OFF); } @Test(description = "POST /vApp/{id}/power/action/shutdown", dependsOnMethods = { "testDeployVApp" }) public void testShutdown() { // Power on VApp - vApp = powerOnVApp(vApp.getHref()); + vApp = powerOnVApp(vAppUrn); // The method under test - Task shutdown = vAppApi.shutdown(vApp.getHref()); + Task shutdown = vAppApi.shutdown(vAppUrn); assertTaskSucceedsLong(shutdown); // Get the edited VApp - vApp = vAppApi.getVApp(vApp.getHref()); + vApp = vAppApi.get(vAppUrn); // Check status - assertVAppStatus(vApp.getHref(), Status.POWERED_OFF); + assertVAppStatus(vAppUrn, Status.POWERED_OFF); // Power on the VApp again - vApp = powerOnVApp(vApp.getHref()); + vApp = powerOnVApp(vAppUrn); } @Test(description = "POST /vApp/{id}/power/action/suspend", dependsOnMethods = { "testDeployVApp" }) public void testSuspend() { // Power on VApp - vApp = powerOnVApp(vApp.getHref()); + vApp = powerOnVApp(vAppUrn); // The method under test - Task suspend = vAppApi.suspend(vAppURI); + Task suspend = vAppApi.suspend(vAppUrn); assertTaskSucceedsLong(suspend); // Get the edited VApp - vApp = vAppApi.getVApp(vApp.getHref()); + vApp = vAppApi.get(vAppUrn); // Check status - assertVAppStatus(vAppURI, Status.SUSPENDED); + assertVAppStatus(vAppUrn, Status.SUSPENDED); // Power on the VApp again - vApp = powerOnVApp(vApp.getHref()); + vApp = powerOnVApp(vAppUrn); } @Test(description = "POST /vApp/{id}/power/action/reset", dependsOnMethods = { "testDeployVApp" }) public void testReset() { // Power on VApp - vApp = powerOnVApp(vApp.getHref()); + vApp = powerOnVApp(vAppUrn); // The method under test - Task reset = vAppApi.reset(vAppURI); + Task reset = vAppApi.reset(vAppUrn); assertTaskSucceedsLong(reset); // Get the edited VApp - vApp = vAppApi.getVApp(vAppURI); + vApp = vAppApi.get(vAppUrn); // Check status - assertVAppStatus(vAppURI, Status.POWERED_ON); + assertVAppStatus(vAppUrn, Status.POWERED_ON); } @Test(description = "POST /vApp/{id}/action/undeploy", dependsOnMethods = { "testDeployVApp" }) public void testUndeployVApp() { // Power on VApp - vApp = powerOnVApp(vApp.getHref()); + vApp = powerOnVApp(vAppUrn); UndeployVAppParams params = UndeployVAppParams.builder().build(); // The method under test - Task undeploy = vAppApi.undeploy(vApp.getHref(), params); + Task undeploy = vAppApi.undeploy(vAppUrn, params); assertTrue(retryTaskSuccess.apply(undeploy), String.format(TASK_COMPLETE_TIMELY, "undeploy")); // Get the edited VApp - vApp = vAppApi.getVApp(vAppURI); + vApp = vAppApi.get(vAppUrn); // Check status assertFalse(vApp.isDeployed(), String.format(OBJ_FIELD_EQ, VAPP, "deployed", "FALSE", vApp.isDeployed().toString())); - assertVAppStatus(vAppURI, Status.POWERED_OFF); + assertVAppStatus(vAppUrn, Status.POWERED_OFF); } @Test(description = "POST /vApp/{id}/power/action/powerOff", dependsOnMethods = { "testUndeployVApp" }) public void testPowerOffVApp() { // Power on VApp - vApp = powerOnVApp(vApp.getHref()); + vApp = powerOnVApp(vAppUrn); // The method under test - Task powerOffVApp = vAppApi.powerOff(vApp.getHref()); + Task powerOffVApp = vAppApi.powerOff(vAppUrn); assertTrue(retryTaskSuccess.apply(powerOffVApp), String.format(TASK_COMPLETE_TIMELY, "powerOffVApp")); // Get the edited VApp - vApp = vAppApi.getVApp(vAppURI); + vApp = vAppApi.get(vAppUrn); // Check status - assertVAppStatus(vAppURI, Status.POWERED_OFF); + assertVAppStatus(vAppUrn, Status.POWERED_OFF); } @Test(description = "POST /vApp/{id}/action/controlAccess", dependsOnMethods = { "testGetVApp" }) @@ -435,7 +435,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { .accessLevel("ReadOnly").build()).build(); // The method under test - ControlAccessParams modified = vAppApi.editControlAccess(vApp.getHref(), params); + ControlAccessParams modified = vAppApi.editControlAccess(vAppUrn, params); // Check the retrieved object is well formed checkControlAccessParams(modified); @@ -450,7 +450,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { .build(); // The method under test - ControlAccessParams modified = vAppApi.editControlAccess(vApp.getHref(), params); + ControlAccessParams modified = vAppApi.editControlAccess(vAppUrn, params); // Check the retrieved object is well formed checkControlAccessParams(modified); @@ -462,11 +462,11 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "POST /vApp/{id}/action/discardSuspendedState", dependsOnMethods = { "testDeployVApp" }) public void testDiscardSuspendedState() { // Power on, then suspend the VApp - vApp = powerOnVApp(vAppURI); - vApp = suspendVApp(vAppURI); + vApp = powerOnVApp(vAppUrn); + vApp = suspendVApp(vAppUrn); // The method under test - Task discardSuspendedState = vAppApi.discardSuspendedState(vApp.getHref()); + Task discardSuspendedState = vAppApi.discardSuspendedState(vAppUrn); assertTrue(retryTaskSuccess.apply(discardSuspendedState), String.format(TASK_COMPLETE_TIMELY, "discardSuspendedState")); } @@ -479,19 +479,19 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { DeployVAppParams params = DeployVAppParams.builder() .deploymentLeaseSeconds((int) TimeUnit.SECONDS.convert(1L, TimeUnit.HOURS)).notForceCustomization() .notPowerOn().build(); - Task deployVApp = vAppApi.deploy(temp.getHref(), params); + Task deployVApp = vAppApi.deploy(temp.getId(), params); assertTaskSucceedsLong(deployVApp); try { // Method under test - vAppApi.enterMaintenanceMode(temp.getHref()); + vAppApi.enterMaintenanceMode(temp.getId()); - temp = vAppApi.getVApp(temp.getHref()); + temp = vAppApi.get(temp.getId()); assertTrue(temp.isInMaintenanceMode(), String.format(CONDITION_FMT, "InMaintenanceMode", "TRUE", temp.isInMaintenanceMode())); // Exit maintenance mode - vAppApi.exitMaintenanceMode(temp.getHref()); + vAppApi.exitMaintenanceMode(temp.getId()); } finally { cleanUpVApp(temp); } @@ -504,17 +504,17 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { DeployVAppParams params = DeployVAppParams.builder() .deploymentLeaseSeconds((int) TimeUnit.SECONDS.convert(1L, TimeUnit.HOURS)).notForceCustomization() .notPowerOn().build(); - Task deployVApp = vAppApi.deploy(temp.getHref(), params); + Task deployVApp = vAppApi.deploy(temp.getId(), params); assertTaskSucceedsLong(deployVApp); try { // Enter maintenance mode - vAppApi.enterMaintenanceMode(temp.getHref()); + vAppApi.enterMaintenanceMode(temp.getId()); // Method under test - vAppApi.exitMaintenanceMode(temp.getHref()); + vAppApi.exitMaintenanceMode(temp.getId()); - temp = vAppApi.getVApp(temp.getHref()); + temp = vAppApi.get(temp.getId()); assertFalse(temp.isInMaintenanceMode(), String.format(CONDITION_FMT, "InMaintenanceMode", "FALSE", temp.isInMaintenanceMode())); } finally { @@ -525,7 +525,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "GET /vApp/{id}/controlAccess", dependsOnMethods = { "testGetVApp" }) public void testGetControlAccess() { // The method under test - ControlAccessParams controlAccess = vAppApi.getControlAccess(vApp.getHref()); + ControlAccessParams controlAccess = vAppApi.getAccessControl(vAppUrn); // Check the retrieved object is well formed checkControlAccessParams(controlAccess); @@ -534,7 +534,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "GET /vApp/{id}/leaseSettingsSection", dependsOnMethods = { "testGetVApp" }) public void testGetLeaseSettingsSection() { // The method under test - LeaseSettingsSection section = vAppApi.getLeaseSettingsSection(vApp.getHref()); + LeaseSettingsSection section = vAppApi.getLeaseSettingsSection(vAppUrn); // Check the retrieved object is well formed checkLeaseSettingsSection(section); @@ -543,17 +543,17 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "PUT /vApp/{id}/leaseSettingsSection", dependsOnMethods = { "testGetLeaseSettingsSection" }) public void testEditLeaseSettingsSection() { // Copy existing section - LeaseSettingsSection oldSection = vAppApi.getLeaseSettingsSection(vApp.getHref()); + LeaseSettingsSection oldSection = vAppApi.getLeaseSettingsSection(vAppUrn); Integer twoHours = (int) TimeUnit.SECONDS.convert(2L, TimeUnit.HOURS); LeaseSettingsSection newSection = oldSection.toBuilder().deploymentLeaseInSeconds(twoHours).build(); // The method under test - Task editLeaseSettingsSection = vAppApi.editLeaseSettingsSection(vApp.getHref(), newSection); + Task editLeaseSettingsSection = vAppApi.editLeaseSettingsSection(vAppUrn, newSection); assertTrue(retryTaskSuccess.apply(editLeaseSettingsSection), String.format(TASK_COMPLETE_TIMELY, "editLeaseSettingsSection")); // Retrieve the modified section - LeaseSettingsSection modified = vAppApi.getLeaseSettingsSection(vApp.getHref()); + LeaseSettingsSection modified = vAppApi.getLeaseSettingsSection(vAppUrn); // Check the retrieved object is well formed checkLeaseSettingsSection(modified); @@ -588,7 +588,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "GET /vApp/{id}/networkConfigSection", dependsOnMethods = { "testGetVApp" }) public void testGetNetworkConfigSection() { // The method under test - NetworkConfigSection section = vAppApi.getNetworkConfigSection(vApp.getHref()); + NetworkConfigSection section = vAppApi.getNetworkConfigSection(vAppUrn); // Check the retrieved object is well formed checkNetworkConfigSection(section); @@ -597,17 +597,17 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "PUT /vApp/{id}/networkConfigSection", dependsOnMethods = { "testGetNetworkConfigSection" }) public void testEditNetworkConfigSection() { // Copy existing section and edit fields - NetworkConfigSection oldSection = vAppApi.getNetworkConfigSection(vApp.getHref()); + NetworkConfigSection oldSection = vAppApi.getNetworkConfigSection(vAppUrn); VAppNetworkConfiguration networkConfig = VAppNetworkConfiguration.builder().build(); NetworkConfigSection newSection = oldSection.toBuilder().networkConfigs(ImmutableSet.of(networkConfig)).build(); // The method under test - Task editNetworkConfigSection = vAppApi.editNetworkConfigSection(vApp.getHref(), newSection); + Task editNetworkConfigSection = vAppApi.editNetworkConfigSection(vAppUrn, newSection); assertTrue(retryTaskSuccess.apply(editNetworkConfigSection), String.format(TASK_COMPLETE_TIMELY, "editNetworkConfigSection")); // Retrieve the modified section - NetworkConfigSection modified = vAppApi.getNetworkConfigSection(vApp.getHref()); + NetworkConfigSection modified = vAppApi.getNetworkConfigSection(vAppUrn); // Check the retrieved object is well formed checkNetworkConfigSection(modified); @@ -622,7 +622,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "GET /vApp/{id}/networkSection", dependsOnMethods = { "testGetVApp" }) public void testGetNetworkSection() { // The method under test - NetworkSection section = vAppApi.getNetworkSection(vApp.getHref()); + NetworkSection section = vAppApi.getNetworkSection(vAppUrn); // Check the retrieved object is well formed checkNetworkSection(section); @@ -631,7 +631,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "GET /vApp/{id}/owner", dependsOnMethods = { "testGetVApp" }) public void testGetOwner() { // The method under test - Owner owner = vAppApi.getOwner(vApp.getHref()); + Owner owner = vAppApi.getOwner(vAppUrn); // Check the retrieved object is well formed checkOwner(owner); @@ -642,10 +642,10 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { Owner newOwner = Owner.builder().user(Reference.builder().href(user.getHref()).type(ADMIN_USER).build()).build(); // The method under test - vAppApi.editOwner(vApp.getHref(), newOwner); + vAppApi.editOwner(vAppUrn, newOwner); // Get the new VApp owner - Owner modified = vAppApi.getOwner(vApp.getHref()); + Owner modified = vAppApi.getOwner(vAppUrn); // Check the retrieved object is well formed checkOwner(modified); @@ -657,7 +657,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "GET /vApp/{id}/productSections", dependsOnMethods = { "testGetVApp" }) public void testGetProductSections() { // The method under test - ProductSectionList sectionList = vAppApi.getProductSections(vApp.getHref()); + ProductSectionList sectionList = vAppApi.getProductSections(vAppUrn); // Check the retrieved object is well formed checkProductSectionList(sectionList); @@ -666,7 +666,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "PUT /vApp/{id}/productSections", dependsOnMethods = { "testGetProductSections" }) public void testEditProductSections() { // Copy existing section and edit fields - ProductSectionList oldSections = vAppApi.getProductSections(vApp.getHref()); + ProductSectionList oldSections = vAppApi.getProductSections(vAppUrn); ProductSectionList newSections = oldSections .toBuilder() .productSection( @@ -678,12 +678,12 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { .build()).build(); // The method under test - Task editProductSections = vAppApi.editProductSections(vApp.getHref(), newSections); + Task editProductSections = vAppApi.editProductSections(vAppUrn, newSections); assertTrue(retryTaskSuccess.apply(editProductSections), String.format(TASK_COMPLETE_TIMELY, "editProductSections")); // Retrieve the modified section - ProductSectionList modified = vAppApi.getProductSections(vApp.getHref()); + ProductSectionList modified = vAppApi.getProductSections(vAppUrn); // Check the retrieved object is well formed checkProductSectionList(modified); @@ -698,7 +698,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "GET /vApp/{id}/startupSection", dependsOnMethods = { "testGetVApp" }) public void testGetStartupSection() { // The method under test - StartupSection section = vAppApi.getStartupSection(vApp.getHref()); + StartupSection section = vAppApi.getStartupSection(vAppUrn); // Check the retrieved object is well formed checkStartupSection(section); @@ -707,15 +707,15 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "PUT /vApp/{id}/startupSection", dependsOnMethods = { "testGetStartupSection" }) public void testEditStartupSection() { // Copy existing section and edit fields - StartupSection oldSection = vAppApi.getStartupSection(vApp.getHref()); + StartupSection oldSection = vAppApi.getStartupSection(vAppUrn); StartupSection newSection = oldSection.toBuilder().build(); // The method under test - Task editStartupSection = vAppApi.editStartupSection(vApp.getHref(), newSection); + Task editStartupSection = vAppApi.editStartupSection(vAppUrn, newSection); assertTrue(retryTaskSuccess.apply(editStartupSection), String.format(TASK_COMPLETE_TIMELY, "editStartupSection")); // Retrieve the modified section - StartupSection modified = vAppApi.getStartupSection(vApp.getHref()); + StartupSection modified = vAppApi.getStartupSection(vAppUrn); // Check the retrieved object is well formed checkStartupSection(modified); @@ -730,10 +730,10 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { key = name("key-"); String value = name("value-"); metadataValue = MetadataValue.builder().value(value).build(); - vAppApi.getMetadataApi().putEntry(vApp.getHref(), key, metadataValue); + vAppApi.getMetadataApi(vAppUrn).putEntry(key, metadataValue); // Retrieve the value, and assert it was set correctly - MetadataValue newMetadataValue = vAppApi.getMetadataApi().getValue(vApp.getHref(), key); + MetadataValue newMetadataValue = vAppApi.getMetadataApi(vAppUrn).getValue(key); // Check the retrieved object is well formed checkMetadataValueFor(VAPP, newMetadataValue, value); @@ -744,10 +744,10 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { key = name("key-"); String value = name("value-"); metadataValue = MetadataValue.builder().value(value).build(); - vAppApi.getMetadataApi().putEntry(vApp.getHref(), key, metadataValue); + vAppApi.getMetadataApi(vAppUrn).putEntry(key, metadataValue); // Call the method being tested - Metadata metadata = vAppApi.getMetadataApi().get(vApp.getHref()); + Metadata metadata = vAppApi.getMetadataApi(vAppUrn).get(); checkMetadata(metadata); @@ -759,7 +759,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "GET /vApp/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadata" }) public void testGetOrgMetadataValue() { // Call the method being tested - MetadataValue value = vAppApi.getMetadataApi().getValue(vApp.getHref(), key); + MetadataValue value = vAppApi.getMetadataApi(vAppUrn).getValue(key); String expected = metadataValue.getValue(); @@ -771,11 +771,11 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "DELETE /vApp/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadataValue" }) public void testRemoveMetadataEntry() { // Delete the entry - Task task = vAppApi.getMetadataApi().removeEntry(vApp.getHref(), key); + Task task = vAppApi.getMetadataApi(vAppUrn).removeEntry(key); retryTaskSuccess.apply(task); // Confirm the entry has been removed - Metadata newMetadata = vAppApi.getMetadataApi().get(vApp.getHref()); + Metadata newMetadata = vAppApi.getMetadataApi(vAppUrn).get(); // Check the retrieved object is well formed checkMetadataKeyAbsentFor(VAPP, newMetadata, key); @@ -783,18 +783,18 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "POST /vApp/{id}/metadata", dependsOnMethods = { "testGetMetadata" }) public void testMergeMetadata() { - Metadata oldMetadata = vAppApi.getMetadataApi().get(vApp.getHref()); + Metadata oldMetadata = vAppApi.getMetadataApi(vAppUrn).get(); Map oldMetadataMap = Checks.metadataToMap(oldMetadata); // Store a value, to be removed String key = name("key-"); String value = name("value-"); Metadata addedMetadata = Metadata.builder().entry(MetadataEntry.builder().key(key).value(value).build()).build(); - Task task = vAppApi.getMetadataApi().merge(vApp.getHref(), addedMetadata); + Task task = vAppApi.getMetadataApi(vAppUrn).merge(addedMetadata); retryTaskSuccess.apply(task); // Confirm the entry contains everything that was there, and everything that was being added - Metadata newMetadata = vAppApi.getMetadataApi().get(vApp.getHref()); + Metadata newMetadata = vAppApi.getMetadataApi(vAppUrn).get(); Map expectedMetadataMap = ImmutableMap. builder().putAll(oldMetadataMap) .put(key, value).build(); @@ -803,7 +803,7 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { } /** - * @see VAppApi#removeVApp(URI) + * @see VAppApi#remove(URI) */ @Test(description = "DELETE /vApp/{id}") public void testRemoveVApp() { @@ -811,10 +811,10 @@ public class VAppApiLiveTest extends AbstractVAppApiLiveTest { VApp temp = instantiateVApp(); // The method under test - Task removeVApp = vAppApi.removeVApp(temp.getHref()); + Task removeVApp = vAppApi.remove(temp.getId()); assertTrue(retryTaskSuccess.apply(removeVApp), String.format(TASK_COMPLETE_TIMELY, "removeVApp")); - VApp removed = vAppApi.getVApp(temp.getHref()); + VApp removed = vAppApi.get(temp.getId()); assertNull(removed, "The VApp " + temp.getName() + " should have been removed"); } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppNetworksLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppNetworksLiveTest.java index 6f2bc3cb17..4e2656e645 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppNetworksLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppNetworksLiveTest.java @@ -22,7 +22,6 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.T import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkNetworkConfigSection; import static org.testng.Assert.assertTrue; -import java.net.URI; import java.util.List; import java.util.Map; import java.util.Set; @@ -79,7 +78,7 @@ public class VAppNetworksLiveTest extends AbstractVAppApiLiveTest { protected void tidyUp() { if (key != null) { try { - Task remove = vAppTemplateApi.getMetadataApi().removeEntry(vAppTemplateURI, key); + Task remove = vAppTemplateApi.getMetadataApi(vAppTemplateUrn).removeEntry(key); taskDoneEventually(remove); } catch (Exception e) { logger.warn(e, "Error when deleting metadata entry '%s'", key); @@ -101,10 +100,10 @@ public class VAppNetworksLiveTest extends AbstractVAppApiLiveTest { @Test(description = "Create a vApp Network based on an org network with `default` firewall rules applied") public void testAddVAppNetworkWithDefaultSecurityGroup() { ImmutableList securityGroups = ImmutableList.of(DEFAULT_SECURITY_GROUP); - addVAppNetworkWithSecurityGroupOnVApp(securityGroups, vAppURI); + addVAppNetworkWithSecurityGroupOnVApp(securityGroups, vAppUrn); // Retrieve the modified section - NetworkConfigSection modified = vAppApi.getNetworkConfigSection(vAppURI); + NetworkConfigSection modified = vAppApi.getNetworkConfigSection(vAppUrn); // Check the retrieved object is well formed checkNetworkConfigSection(modified); @@ -120,10 +119,10 @@ public class VAppNetworksLiveTest extends AbstractVAppApiLiveTest { @Test(description = "Create a vApp Network based on an org network with `http` firewall rules applied") public void testAddVAppNetworkWithHttpSecurityGroup() { ImmutableList securityGroups = ImmutableList.of(HTTP_SECURITY_GROUP); - addVAppNetworkWithSecurityGroupOnVApp(securityGroups, vAppURI); + addVAppNetworkWithSecurityGroupOnVApp(securityGroups, vAppUrn); // Retrieve the modified section - NetworkConfigSection modified = vAppApi.getNetworkConfigSection(vAppURI); + NetworkConfigSection modified = vAppApi.getNetworkConfigSection(vAppUrn); // Check the retrieved object is well formed checkNetworkConfigSection(modified); @@ -139,10 +138,10 @@ public class VAppNetworksLiveTest extends AbstractVAppApiLiveTest { @Test(description = "Create a vApp Network based on an org network with both `defautl` and `http` firewall rules applied") public void testAddVAppNetworkWithDefaultAndHttpSecurityGroup() { ImmutableList securityGroups = ImmutableList.of(DEFAULT_SECURITY_GROUP, HTTP_SECURITY_GROUP); - addVAppNetworkWithSecurityGroupOnVApp(securityGroups, vAppURI); + addVAppNetworkWithSecurityGroupOnVApp(securityGroups, vAppUrn); // Retrieve the modified section - NetworkConfigSection modified = vAppApi.getNetworkConfigSection(vAppURI); + NetworkConfigSection modified = vAppApi.getNetworkConfigSection(vAppUrn); // Check the retrieved object is well formed checkNetworkConfigSection(modified); @@ -155,11 +154,11 @@ public class VAppNetworksLiveTest extends AbstractVAppApiLiveTest { */ } - private void addVAppNetworkWithSecurityGroupOnVApp(ImmutableList securityGroups, URI vAppURI) { + private void addVAppNetworkWithSecurityGroupOnVApp(ImmutableList securityGroups, String vAppUrn) { String newVAppNetworkName = generateVAppNetworkName(network.getName(), securityGroups); // Create a vAppNetwork with firewall rules NetworkConfigSection newSection = generateNetworkConfigSection(securityGroups, newVAppNetworkName); - Task editNetworkConfigSection = vAppApi.editNetworkConfigSection(vAppURI, newSection); + Task editNetworkConfigSection = vAppApi.editNetworkConfigSection(vAppUrn, newSection); assertTrue(retryTaskSuccess.apply(editNetworkConfigSection), String.format(TASK_COMPLETE_TIMELY, "editNetworkConfigSection")); attachVmToVAppNetwork(vm, newVAppNetworkName); } @@ -191,7 +190,7 @@ public class VAppNetworksLiveTest extends AbstractVAppApiLiveTest { } private void attachVmToVAppNetwork(Vm vm, String vAppNetworkName) { - Set networkConnections = vmApi.getNetworkConnectionSection(vm.getHref()) + Set networkConnections = vmApi.getNetworkConnectionSection(vm.getId()) .getNetworkConnections(); NetworkConnectionSection section = NetworkConnectionSection.builder() @@ -209,7 +208,7 @@ public class VAppNetworksLiveTest extends AbstractVAppApiLiveTest { section = section.toBuilder().networkConnection(newNetworkConnection).build(); } - Task configureNetwork = vmApi.editNetworkConnectionSection(vm.getHref(), section); + Task configureNetwork = vmApi.editNetworkConnectionSection(vm.getId(), section); assertTaskSucceedsLong(configureNetwork); } @@ -333,7 +332,7 @@ public class VAppNetworksLiveTest extends AbstractVAppApiLiveTest { private void disconnectVmFromVAppNetwork(Vm vm) { - Set networkConnections = vmApi.getNetworkConnectionSection(vm.getHref()) + Set networkConnections = vmApi.getNetworkConnectionSection(vm.getId()) .getNetworkConnections(); NetworkConnectionSection section = NetworkConnectionSection.builder() @@ -350,7 +349,7 @@ public class VAppNetworksLiveTest extends AbstractVAppApiLiveTest { .build()) .build(); } - Task cleanUpNetworks = vmApi.editNetworkConnectionSection(vm.getHref(), section); + Task cleanUpNetworks = vmApi.editNetworkConnectionSection(vm.getId(), section); assertTaskSucceedsLong(cleanUpNetworks); } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateApiExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateApiExpectTest.java index 16ec1a7b19..7bf687ba61 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateApiExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateApiExpectTest.java @@ -21,12 +21,10 @@ package org.jclouds.vcloud.director.v1_5.features; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.ANY; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.CUSTOMIZATION_SECTION; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.ERROR; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.GUEST_CUSTOMIZATION_SECTION; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.LEASE_SETTINGS_SECTION; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.METADATA; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.METADATA_ENTRY; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NETWORK_CONFIG_SECTION; -import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.RELOCATE_TEMPLATE; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.TASK; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.VAPP_TEMPLATE; import static org.testng.Assert.assertEquals; @@ -50,7 +48,6 @@ import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.Vm; -import org.jclouds.vcloud.director.v1_5.domain.params.RelocateParams; import org.jclouds.vcloud.director.v1_5.domain.section.CustomizationSection; import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection; import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection; @@ -86,14 +83,14 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest ).getVAppTemplateApi(); assertNotNull(api); - VAppTemplate template = api.getVAppTemplate(uri); + VAppTemplate template = api.get(uri); assertEquals(template, exampleTemplate()); - Task task = api.editVAppTemplate(uri, exampleTemplate()); + Task task = api.edit(uri, exampleTemplate()); assertNotNull(task); - task = api.removeVappTemplate(uri); + task = api.remove(uri); assertNotNull(task); } @@ -106,7 +103,7 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest new VcloudHttpRequestPrimer().apiCommand("GET", templateId).acceptMedia(VAPP_TEMPLATE).httpRequestBuilder().build(), new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateApi(); - api.getVAppTemplate(uri); + api.get(uri); } @Test(expectedExceptions = ResourceNotFoundException.class) @@ -118,7 +115,7 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest new VcloudHttpRequestPrimer().apiCommand("PUT", templateId).xmlFilePayload("/vapptemplate/vAppTemplate.xml", VAPP_TEMPLATE).acceptMedia(TASK).httpRequestBuilder().build(), new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error403.xml", ERROR).httpResponseBuilder().statusCode(403).build()).getVAppTemplateApi(); - api.editVAppTemplate(uri, exampleTemplate()); + api.edit(uri, exampleTemplate()); } @Test(expectedExceptions = VCloudDirectorException.class) @@ -130,33 +127,7 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest new VcloudHttpRequestPrimer().apiCommand("DELETE", templateId).acceptMedia(TASK).httpRequestBuilder().build(), new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateApi(); - api.removeVappTemplate(uri); - } - - public void testConsolidateVAppTemplate() { - final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"; - URI uri = URI.create(endpoint + templateId); - - VAppTemplateApi api = requestsSendResponses(loginRequest, sessionResponse, - new VcloudHttpRequestPrimer().apiCommand("POST", templateId + "/action/consolidate").acceptMedia(TASK).httpRequestBuilder().build(), - new VcloudHttpResponsePrimer().xmlFilePayload("/task/task.xml", TASK).httpResponseBuilder().build() - ).getVAppTemplateApi(); - - assertNotNull(api); - Task task = api.consolidateVm(uri); - assertNotNull(task); - } - - @Test(expectedExceptions = ResourceNotFoundException.class) - public void testConsolidateMissingVAppTemplate() { - final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"; - URI uri = URI.create(endpoint + templateId); - - VAppTemplateApi api = orderedRequestsSendResponses(loginRequest, sessionResponse, - new VcloudHttpRequestPrimer().apiCommand("POST", templateId + "/action/consolidate").acceptMedia(TASK).httpRequestBuilder().build(), - new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error403.xml", ERROR).httpResponseBuilder().statusCode(403).build()).getVAppTemplateApi(); - - api.consolidateVm(uri); + api.remove(uri); } public void testDisableDownloadVAppTemplate() { @@ -209,39 +180,6 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest api.enableDownload(uri); } - - public void testRelocateVAppTemplate() { - final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"; - URI uri = URI.create(endpoint + templateId); - - VAppTemplateApi api = requestsSendResponses(loginRequest, sessionResponse, - new VcloudHttpRequestPrimer().apiCommand("POST", templateId + "/action/relocate").xmlFilePayload("/vapptemplate/relocateParams.xml", RELOCATE_TEMPLATE).acceptMedia(TASK).httpRequestBuilder().build(), - new VcloudHttpResponsePrimer().xmlFilePayload("/task/task.xml", TASK).httpResponseBuilder().build() - ).getVAppTemplateApi(); - - assertNotNull(api); - - Reference datastore = Reference.builder().href(URI.create("https://vcloud.example.com/api/admin/extension/datastore/607")).build(); - RelocateParams params = RelocateParams.builder().datastore(datastore).build(); - - Task task = api.relocateVm(uri, params); - assertNotNull(task); - } - - @Test(expectedExceptions = VCloudDirectorException.class) - public void testRelocateMissingVAppTemplate() { - final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"; - URI uri = URI.create(endpoint + templateId); - - VAppTemplateApi api = orderedRequestsSendResponses(loginRequest, sessionResponse, - new VcloudHttpRequestPrimer().apiCommand("POST", templateId + "/action/relocate").xmlFilePayload("/vapptemplate/relocateParams.xml", RELOCATE_TEMPLATE).acceptMedia(TASK).httpRequestBuilder().build(), - new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateApi(); - - Reference datastore = Reference.builder().href(URI.create("https://vcloud.example.com/api/admin/extension/datastore/607")).build(); - RelocateParams params = RelocateParams.builder().datastore(datastore).build(); - - api.relocateVm(uri, params); - } public void testErrorGetCustomizationSection() { final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"; @@ -254,50 +192,6 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest assertNull(api.getCustomizationSection(uri)); } - public void testGuestCustomizationSection() { - final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"; - URI uri = URI.create(endpoint + templateId); - - VAppTemplateApi api = orderedRequestsSendResponses(loginRequest, sessionResponse, - new VcloudHttpRequestPrimer().apiCommand("GET", templateId + "/guestCustomizationSection").acceptMedia(GUEST_CUSTOMIZATION_SECTION).httpRequestBuilder().build(), - new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/guestCustomizationSection.xml", GUEST_CUSTOMIZATION_SECTION).httpResponseBuilder().build(), - new VcloudHttpRequestPrimer().apiCommand("PUT", templateId + "/guestCustomizationSection").xmlFilePayload("/vapptemplate/guestCustomizationSection.xml", GUEST_CUSTOMIZATION_SECTION).acceptMedia(TASK).httpRequestBuilder().build(), - new VcloudHttpResponsePrimer().xmlFilePayload("/task/task.xml", TASK).httpResponseBuilder().build() - ).getVAppTemplateApi(); - - assertNotNull(api); - GuestCustomizationSection section = api.getGuestCustomizationSection(uri); - - assertEquals(section, exampleGuestCustomizationSection()); - - Task task = api.editGuestCustomizationSection(uri, exampleGuestCustomizationSection()); - assertNotNull(task); - } - - @Test(expectedExceptions = VCloudDirectorException.class) - public void testErrorGetGuestCustomizationSection() { - final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"; - URI uri = URI.create(endpoint + templateId); - - VAppTemplateApi api = orderedRequestsSendResponses(loginRequest, sessionResponse, - new VcloudHttpRequestPrimer().apiCommand("GET", templateId + "/guestCustomizationSection").acceptMedia(GUEST_CUSTOMIZATION_SECTION).httpRequestBuilder().build(), - new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateApi(); - - api.getGuestCustomizationSection(uri); - } - - @Test(expectedExceptions = VCloudDirectorException.class) - public void testErrorEditGuestCustomizationSection() { - final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"; - URI uri = URI.create(endpoint + templateId); - - VAppTemplateApi api = orderedRequestsSendResponses(loginRequest, sessionResponse, - new VcloudHttpRequestPrimer().apiCommand("PUT", templateId + "/guestCustomizationSection").xmlFilePayload("/vapptemplate/guestCustomizationSection.xml", GUEST_CUSTOMIZATION_SECTION).acceptMedia(TASK).httpRequestBuilder().build(), - new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateApi(); - - api.editGuestCustomizationSection(uri, exampleGuestCustomizationSection()); - } - public void testLeaseSettingsSection() throws ParseException { final String templateId = "/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"; URI uri = URI.create(endpoint + templateId); @@ -353,11 +247,11 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest ).getVAppTemplateApi(); assertNotNull(api); - Metadata metadata = api.getMetadataApi().get(uri); + Metadata metadata = api.getMetadataApi(uri).get(); assertEquals(metadata, exampleMetadata()); - Task task = api.getMetadataApi().merge(uri, exampleMetadata()); + Task task = api.getMetadataApi(uri).merge(exampleMetadata()); assertNotNull(task); } @@ -370,7 +264,7 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest new VcloudHttpRequestPrimer().apiCommand("GET", templateId + "/metadata").acceptMedia(ANY).httpRequestBuilder().build(), new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateApi(); - api.getMetadataApi().get(uri); + api.getMetadataApi(uri).get(); } @Test(expectedExceptions = VCloudDirectorException.class) @@ -382,7 +276,7 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest new VcloudHttpRequestPrimer().apiCommand("POST", templateId + "/metadata").xmlFilePayload("/vapptemplate/metadata.xml", METADATA).acceptMedia(TASK).httpRequestBuilder().build(), new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateApi(); - api.getMetadataApi().merge(uri, exampleMetadata()); + api.getMetadataApi(uri).merge(exampleMetadata()); } public void testVappTemplateMetadataValue() { @@ -399,14 +293,14 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest ).getVAppTemplateApi(); assertNotNull(api); - MetadataValue metadata = api.getMetadataApi().getValue(uri, "12345"); + MetadataValue metadata = api.getMetadataApi(uri).getValue("12345"); assertEquals(metadata, exampleMetadataValue()); - Task task = api.getMetadataApi().putEntry(uri, "12345", exampleMetadataValue()); + Task task = api.getMetadataApi(uri).putEntry("12345", exampleMetadataValue()); assertNotNull(task); - task = api.getMetadataApi().removeEntry(uri, "12345"); + task = api.getMetadataApi(uri).removeEntry("12345"); assertNotNull(task); } @@ -418,7 +312,7 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest new VcloudHttpRequestPrimer().apiCommand("GET", templateId + "/metadata/12345").acceptMedia(METADATA_ENTRY).httpRequestBuilder().build(), new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error403.xml", ERROR).httpResponseBuilder().statusCode(403).build()).getVAppTemplateApi(); - assertNull(api.getMetadataApi().getValue(uri, "12345")); + assertNull(api.getMetadataApi(uri).getValue("12345")); } @Test(expectedExceptions = VCloudDirectorException.class) @@ -430,7 +324,7 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest new VcloudHttpRequestPrimer().apiCommand("PUT", templateId + "/metadata/12345").xmlFilePayload("/vapptemplate/metadataValue.xml", METADATA_ENTRY).acceptMedia(TASK).httpRequestBuilder().build(), new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateApi(); - api.getMetadataApi().putEntry(uri, "12345", exampleMetadataValue()); + api.getMetadataApi(uri).putEntry("12345", exampleMetadataValue()); } @Test(expectedExceptions = ResourceNotFoundException.class) @@ -442,7 +336,7 @@ public class VAppTemplateApiExpectTest extends VCloudDirectorAdminApiExpectTest new VcloudHttpRequestPrimer().apiCommand("DELETE", templateId + "/metadata/12345").acceptMedia(TASK).httpRequestBuilder().build(), new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error403.xml", ERROR).httpResponseBuilder().statusCode(403).build()).getVAppTemplateApi(); - api.getMetadataApi().removeEntry(uri, "12345"); + api.getMetadataApi(uri).removeEntry("12345"); } @Test(expectedExceptions = VCloudDirectorException.class) diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateApiLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateApiLiveTest.java index 72e45426b0..341c38e17f 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateApiLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VAppTemplateApiLiveTest.java @@ -19,7 +19,6 @@ package org.jclouds.vcloud.director.v1_5.features; import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkCustomizationSection; -import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkGuestCustomizationSection; import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkLeaseSettingsSection; import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadata; import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadataFor; @@ -38,7 +37,6 @@ import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; -import java.net.URI; import java.util.EnumSet; import java.util.List; import java.util.Map; @@ -46,7 +44,6 @@ import java.util.Set; import org.jclouds.dmtf.ovf.NetworkSection; import org.jclouds.vcloud.director.v1_5.AbstractVAppApiLiveTest; -import org.jclouds.vcloud.director.v1_5.domain.Checks; import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Link.Rel; import org.jclouds.vcloud.director.v1_5.domain.Metadata; @@ -55,17 +52,13 @@ 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.ProductSectionList; import org.jclouds.vcloud.director.v1_5.domain.Reference; -import org.jclouds.vcloud.director.v1_5.domain.References; import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate; import org.jclouds.vcloud.director.v1_5.domain.dmtf.Envelope; import org.jclouds.vcloud.director.v1_5.domain.params.CloneVAppTemplateParams; -import org.jclouds.vcloud.director.v1_5.domain.params.RelocateParams; import org.jclouds.vcloud.director.v1_5.domain.section.CustomizationSection; -import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection; import org.jclouds.vcloud.director.v1_5.domain.section.LeaseSettingsSection; import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConfigSection; -import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection; import org.testng.annotations.AfterClass; import org.testng.annotations.Test; @@ -78,7 +71,7 @@ import com.google.common.collect.Iterables; * Tests the request/response behavior of {@link VAppTemplateApi} * * NOTE The environment MUST have at least one template configured - * + * * @author Aled Sage */ @Test(groups = { "live", "user" }, singleThreaded = true, testName = "VAppTemplateApiLiveTest") @@ -91,22 +84,20 @@ public class VAppTemplateApiLiveTest extends AbstractVAppApiLiveTest { protected void tidyUp() { if (key != null) { try { - Task remove = vAppTemplateApi.getMetadataApi().removeEntry(vAppTemplateURI, key); - taskDoneEventually(remove); + Task remove = vAppTemplateApi.getMetadataApi(vAppTemplateUrn).removeEntry(key); + taskDoneEventually(remove); } catch (Exception e) { logger.warn(e, "Error when deleting metadata entry '%s'", key); } } } - + private VAppTemplate cloneVAppTemplate(boolean waitForTask) throws Exception { CloneVAppTemplateParams cloneVAppTemplateParams = CloneVAppTemplateParams.builder() - .source(Reference.builder().href(vAppTemplateURI).build()) - .isSourceDelete(false) - .name("clone") - .build(); + .source(Reference.builder().href(lazyGetVAppTemplate().getHref()).build()).isSourceDelete(false) + .name("clone").build(); VAppTemplate clonedVappTemplate = vdcApi.cloneVAppTemplate(vdcUrn, cloneVAppTemplateParams); - + if (waitForTask) { Task cloneTask = Iterables.getFirst(clonedVappTemplate.getTasks(), null); assertNotNull(cloneTask, "vdcApi.cloneVAppTemplate returned VAppTemplate that did not contain any tasks"); @@ -117,112 +108,93 @@ public class VAppTemplateApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "GET /vAppTemplate/{id}") public void testGetVAppTemplate() { - vAppTemplate = vAppTemplateApi.getVAppTemplate(vAppTemplateURI); - + vAppTemplate = vAppTemplateApi.get(vAppTemplateUrn); + checkVAppTemplate(vAppTemplate); - assertEquals(vAppTemplate.getHref(), vAppTemplateURI); + assertEquals(vAppTemplate.getId(), vAppTemplateUrn); } - + @Test(description = "GET /vAppTemplate/{id}/owner") public void testGetVAppTemplateOwner() { - Owner owner = vAppTemplateApi.getOwner(vAppTemplateURI); - + Owner owner = vAppTemplateApi.getOwner(vAppTemplateUrn); + checkOwner(owner); - assertEquals(owner.getUser(), vAppTemplateApi.getVAppTemplate(vAppTemplateURI).getOwner().getUser()); + assertEquals(owner.getUser(), vAppTemplateApi.get(vAppTemplateUrn).getOwner().getUser()); } - + @Test(description = "GET /vAppTemplate/{id}/customizationSection") public void testGetCustomizationSection() { - CustomizationSection customizationSection = vAppTemplateApi.getCustomizationSection(vAppTemplateURI); - + CustomizationSection customizationSection = vAppTemplateApi.getCustomizationSection(vAppTemplateUrn); + checkCustomizationSection(customizationSection); } - + @Test(description = "GET /vAppTemplate/{id}/productSections") public void testGetProductSections() { - ProductSectionList productSectionList = vAppTemplateApi.getProductSections(vAppTemplateURI); - + ProductSectionList productSectionList = vAppTemplateApi.getProductSections(vAppTemplateUrn); + checkProductSectionList(productSectionList); } - + @Test(description = "PUT /vAppTemplate/{id}/productSections") public void testEditProductSections() { // TODO make a real modification - - ProductSectionList origSections = vAppTemplateApi.getProductSections(vApp.getHref()); + + ProductSectionList origSections = vAppTemplateApi.getProductSections(vApp.getId()); ProductSectionList newSections = origSections.toBuilder().build(); - - Task task = vAppTemplateApi.editProductSections(vApp.getHref(), newSections); + + Task task = vAppTemplateApi.editProductSections(vApp.getId(), newSections); assertTaskSucceeds(task); - ProductSectionList modified = vAppTemplateApi.getProductSections(vApp.getHref()); + ProductSectionList modified = vAppTemplateApi.getProductSections(vApp.getId()); checkProductSectionList(modified); } - @Test(description = "GET /vAppTemplate/{id}/guestCustomizationSection") - public void testGetGuestCustomizationSection() { - getGuestCustomizationSection(new Function() { - @Override - public GuestCustomizationSection apply(URI uri) { - return vAppTemplateApi.getGuestCustomizationSection(uri); - } - }); - } - @Test(description = "GET /vAppTemplate/{id}/leaseSettingsSection") public void testGetLeaseSettingsSection() { - LeaseSettingsSection leaseSettingsSection = vAppTemplateApi.getLeaseSettingsSection(vAppTemplateURI); - + LeaseSettingsSection leaseSettingsSection = vAppTemplateApi.getLeaseSettingsSection(vAppTemplateUrn); + checkLeaseSettingsSection(leaseSettingsSection); } - + @Test(description = "GET /vAppTemplate/{id}/metadata", dependsOnMethods = { "testEditMetadataValue" }) public void testGetVAppTemplateMetadata() { - Metadata metadata = vAppTemplateApi.getMetadataApi().get(vAppTemplateURI); - + Metadata metadata = vAppTemplateApi.getMetadataApi(vAppTemplateUrn).get(); + checkMetadata(metadata); } - // implicitly tested by testEditVAppTemplateMetadataValue, which first adds the metadata entry; otherwise no entry may exist + // implicitly tested by testEditVAppTemplateMetadataValue, which first adds the metadata entry; + // otherwise no entry may exist @Test(description = "GET /vAppTemplate/{id}/metadata/{key}", dependsOnMethods = { "testGetVAppTemplateMetadata" }) public void testGetMetadataValue() { - Metadata metadata = vAppTemplateApi.getMetadataApi().get(vAppTemplateURI); + Metadata metadata = vAppTemplateApi.getMetadataApi(vAppTemplateUrn).get(); MetadataEntry entry = Iterables.get(metadata.getMetadataEntries(), 0); - - MetadataValue val = vAppTemplateApi.getMetadataApi().getValue(vAppTemplateURI, entry.getKey()); - + + MetadataValue val = vAppTemplateApi.getMetadataApi(vAppTemplateUrn).getValue(entry.getKey()); + checkMetadataValue(val); assertEquals(val.getValue(), entry.getValue()); } - + @Test(description = "GET /vAppTemplate/{id}/networkConfigSection") public void testGetVAppTemplateNetworkConfigSection() { - NetworkConfigSection networkConfigSection = vAppTemplateApi.getNetworkConfigSection(vAppTemplateURI); - + NetworkConfigSection networkConfigSection = vAppTemplateApi.getNetworkConfigSection(vAppTemplateUrn); + checkNetworkConfigSection(networkConfigSection); } - - @Test(description = "GET /vAppTemplate/{id}/networkConnectionSection") - public void testGetNetworkConnectionSection() { - getNetworkConnectionSection(new Function() { - @Override - public NetworkConnectionSection apply(URI uri) { - return vAppTemplateApi.getNetworkConnectionSection(uri); - } - }); - } @Test(description = "GET /vAppTemplate/{id}/networkSection") public void testGetVAppTemplateNetworkSection() { - NetworkSection networkSection = vAppTemplateApi.getNetworkSection(vAppTemplateURI); + NetworkSection networkSection = vAppTemplateApi.getNetworkSection(vAppTemplateUrn); checkOvfNetworkSection(networkSection); } @Test(description = "GET /vAppTemplate/{id}/ovf") public void testGetVAppTemplateOvf() { - Envelope envelope = vAppTemplateApi.getOvf(vAppTemplateURI); - + Envelope envelope = vAppTemplateApi.getOvf(vAppTemplateUrn); + checkOvfEnvelope(envelope); } @@ -230,197 +202,146 @@ public class VAppTemplateApiLiveTest extends AbstractVAppApiLiveTest { public void testEditVAppTemplate() { String name = name("myname-"); String description = name("Description "); - VAppTemplate template = VAppTemplate.builder() - .name(name) - .description(description) - .build(); - - final Task task = vAppTemplateApi.editVAppTemplate(vAppTemplateURI, template); + VAppTemplate template = VAppTemplate.builder().name(name).description(description).build(); + + final Task task = vAppTemplateApi.edit(vAppTemplateUrn, template); assertTaskSucceeds(task); - VAppTemplate newTemplate = vAppTemplateApi.getVAppTemplate(vAppTemplateURI); + VAppTemplate newTemplate = vAppTemplateApi.get(vAppTemplateUrn); assertEquals(newTemplate.getName(), name); assertEquals(newTemplate.getDescription(), description); } @Test(description = "POST /vAppTemplate/{id}/metadata", dependsOnMethods = { "testGetVAppTemplate" }) public void testEditMetadata() { - Metadata oldMetadata = vAppTemplateApi.getMetadataApi().get(vAppTemplateURI); - Map oldMetadataMap = metadataToMap(oldMetadata); + Metadata oldMetadata = vAppTemplateApi.getMetadataApi(vAppTemplateUrn).get(); + Map oldMetadataMap = metadataToMap(oldMetadata); key = name("key-"); val = name("value-"); MetadataEntry metadataEntry = MetadataEntry.builder().entry(key, val).build(); Metadata metadata = Metadata.builder().fromMetadata(oldMetadata).entry(metadataEntry).build(); - - final Task task = vAppTemplateApi.getMetadataApi().merge(vAppTemplateURI, metadata); + + final Task task = vAppTemplateApi.getMetadataApi(vAppTemplateUrn).merge(metadata); assertTaskSucceeds(task); - Metadata newMetadata = vAppTemplateApi.getMetadataApi().get(vAppTemplateURI); - Map expectedMetadataMap = ImmutableMap.builder() - .putAll(oldMetadataMap) - .put(key, val) - .build(); + Metadata newMetadata = vAppTemplateApi.getMetadataApi(vAppTemplateUrn).get(); + Map expectedMetadataMap = ImmutableMap. builder().putAll(oldMetadataMap) + .put(key, val).build(); checkMetadataFor("vAppTemplate", newMetadata, expectedMetadataMap); } - + @Test(description = "PUT /vAppTemplate/{id}/metadata/{key}", dependsOnMethods = { "testEditMetadata" }) public void testEditMetadataValue() { - val = "new"+val; + val = "new" + val; MetadataValue metadataValue = MetadataValue.builder().value(val).build(); - - final Task task = vAppTemplateApi.getMetadataApi().putEntry(vAppTemplateURI, key, metadataValue); + + final Task task = vAppTemplateApi.getMetadataApi(vAppTemplateUrn).putEntry(key, metadataValue); retryTaskSuccess.apply(task); - MetadataValue newMetadataValue = vAppTemplateApi.getMetadataApi().getValue(vAppTemplateURI, key); + MetadataValue newMetadataValue = vAppTemplateApi.getMetadataApi(vAppTemplateUrn).getValue(key); assertEquals(newMetadataValue.getValue(), metadataValue.getValue()); } @Test(description = "DELETE /vAppTemplate/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadataValue" }) public void testRemoveVAppTemplateMetadataValue() { - final Task deletionTask = vAppTemplateApi.getMetadataApi().removeEntry(vAppTemplateURI, key); + final Task deletionTask = vAppTemplateApi.getMetadataApi(vAppTemplateUrn).removeEntry(key); assertTaskSucceeds(deletionTask); - Metadata newMetadata = vAppTemplateApi.getMetadataApi().get(vAppTemplateURI); + Metadata newMetadata = vAppTemplateApi.getMetadataApi(vAppTemplateUrn).get(); checkMetadataKeyAbsentFor("vAppTemplate", newMetadata, key); key = null; } - @Test(description = "PUT /vAppTemplate/{id}/guestCustomizationSection") - public void testEditGuestCustomizationSection() { - String computerName = name("n"); - GuestCustomizationSection newSection = GuestCustomizationSection.builder() - .info("") - .computerName(computerName) - .build(); - - final Task task = vAppTemplateApi.editGuestCustomizationSection(vm.getHref(), newSection); - assertTaskSucceeds(task); - - GuestCustomizationSection modified = vAppTemplateApi.getGuestCustomizationSection(vm.getHref()); - - checkGuestCustomizationSection(modified); - assertEquals(modified.getComputerName(), computerName); - } - // NOTE vAppTemplate supports only storageLease (deployment lease applies to vApp too) @Test(description = "PUT /vAppTemplate/{id}/leaseSettingsSection") public void testEditLeaseSettingsSection() throws Exception { // NOTE use smallish number for storageLeaseInSeconds; it seems to be capped at 5184000? - int storageLeaseInSeconds = random.nextInt(10000)+1; + int storageLeaseInSeconds = random.nextInt(10000) + 1; - LeaseSettingsSection leaseSettingSection = LeaseSettingsSection.builder() - .info("my info") - .storageLeaseInSeconds(storageLeaseInSeconds) - .build(); - - final Task task = vAppTemplateApi.editLeaseSettingsSection(vAppTemplateURI, leaseSettingSection); + LeaseSettingsSection leaseSettingSection = LeaseSettingsSection.builder().info("my info") + .storageLeaseInSeconds(storageLeaseInSeconds).build(); + + final Task task = vAppTemplateApi.editLeaseSettingsSection(vAppTemplateUrn, leaseSettingSection); assertTaskSucceeds(task); - - LeaseSettingsSection newLeaseSettingsSection = vAppTemplateApi.getLeaseSettingsSection(vAppTemplateURI); + + LeaseSettingsSection newLeaseSettingsSection = vAppTemplateApi.getLeaseSettingsSection(vAppTemplateUrn); assertEquals(newLeaseSettingsSection.getStorageLeaseInSeconds(), (Integer) storageLeaseInSeconds); } - @Test(description = "DELETE /vAppTemplate/{id}", dependsOnMethods = { "testGetVAppTemplate" }) + @Test(description = "DELETE /vAppTemplate/{id}", dependsOnMethods = { "testGetVAppTemplate" }) public void testRemoveVAppTemplate() throws Exception { VAppTemplate clonedVappTemplate = cloneVAppTemplate(true); // Confirm that "get" works pre-remove - VAppTemplate vAppTemplatePreDelete = vAppTemplateApi.getVAppTemplate(clonedVappTemplate.getHref()); + VAppTemplate vAppTemplatePreDelete = vAppTemplateApi.get(clonedVappTemplate.getId()); checkVAppTemplate(vAppTemplatePreDelete); - + // Delete the template - final Task task = vAppTemplateApi.removeVappTemplate(clonedVappTemplate.getHref()); + final Task task = vAppTemplateApi.remove(clonedVappTemplate.getId()); assertTaskSucceeds(task); // Confirm that can't access post-remove, i.e. template has been removed - VAppTemplate removed = vAppTemplateApi.getVAppTemplate(clonedVappTemplate.getHref()); + VAppTemplate removed = vAppTemplateApi.get(clonedVappTemplate.getId()); assertNull(removed); } @Test(description = "POST /vAppTemplate/{id}/action/disableDownload") public void testDisableVAppTemplateDownload() throws Exception { - vAppTemplateApi.disableDownload(vAppTemplateURI); - - // TODO Check that it really is disabled. The only thing I can see for determining this + vAppTemplateApi.disableDownload(vAppTemplateUrn); + + // TODO Check that it really is disabled. The only thing I can see for determining this // is the undocumented "download" link in the VAppTemplate. But that is brittle and we // don't know what timing guarantees there are for adding/removing the link. - VAppTemplate vAppTemplate = vAppTemplateApi.getVAppTemplate(vAppTemplateURI); + VAppTemplate vAppTemplate = vAppTemplateApi.get(vAppTemplateUrn); Set links = vAppTemplate.getLinks(); - assertTrue(Iterables.all(Iterables.transform(links, rel), Predicates.not(Predicates.in(EnumSet.of(Link.Rel.DOWNLOAD_DEFAULT, Link.Rel.DOWNLOAD_ALTERNATE)))), - "Should not offer download link after disabling download: "+vAppTemplate); + assertTrue(Iterables.all(Iterables.transform(links, rel), + Predicates.not(Predicates.in(EnumSet.of(Link.Rel.DOWNLOAD_DEFAULT, Link.Rel.DOWNLOAD_ALTERNATE)))), + "Should not offer download link after disabling download: " + vAppTemplate); } - + @Test(description = "POST /vAppTemplate/{id}/action/enableDownload") public void testEnableVAppTemplateDownload() throws Exception { // First disable so that enable really has some work to do... - vAppTemplateApi.disableDownload(vAppTemplateURI); - final Task task = vAppTemplateApi.enableDownload(vAppTemplateURI); + vAppTemplateApi.disableDownload(vAppTemplateUrn); + final Task task = vAppTemplateApi.enableDownload(vAppTemplateUrn); assertTaskSucceeds(task); - - // TODO Check that it really is enabled. The only thing I can see for determining this + + // TODO Check that it really is enabled. The only thing I can see for determining this // is the undocumented "download" link in the VAppTemplate. But that is brittle and we // don't know what timing guarantees there are for adding/removing the link. - VAppTemplate vAppTemplate = vAppTemplateApi.getVAppTemplate(vAppTemplateURI); + VAppTemplate vAppTemplate = vAppTemplateApi.get(vAppTemplateUrn); Set links = vAppTemplate.getLinks(); - assertTrue(Iterables.any(Iterables.transform(links, rel), Predicates.in(EnumSet.of(Link.Rel.DOWNLOAD_DEFAULT, Link.Rel.DOWNLOAD_ALTERNATE))), - "Should offer download link after enabling download: "+vAppTemplate); + assertTrue( + Iterables.any(Iterables.transform(links, rel), + Predicates.in(EnumSet.of(Link.Rel.DOWNLOAD_DEFAULT, Link.Rel.DOWNLOAD_ALTERNATE))), + "Should offer download link after enabling download: " + vAppTemplate); } - + private Function rel = new Function() { @Override public Rel apply(Link input) { return input.getRel(); } }; - - @Test(description = "POST /vAppTemplate/{id}/action/consolidate") - public void testConsolidateVAppTemplate() throws Exception { - final Task task = vAppTemplateApi.consolidateVm(vm.getHref()); - assertTaskSucceedsLong(task); - - // TODO Need assertion that command had effect - } - - // TODO How to obtain a datastore reference? - @Test(description = "POST /vAppTemplate/{id}/action/relocate") - public void testRelocateVAppTemplate() throws Exception { - Reference dataStore = null; // FIXME - RelocateParams relocateParams = RelocateParams.builder() - .datastore(dataStore) - .build(); - - final Task task = vAppTemplateApi.relocateVm(vAppTemplateURI, relocateParams); - assertTaskSucceedsLong(task); - // TODO Need assertion that command had effect - } - - // NOTE This will fail unless we can relocate a template to another datastore - @Test(description = "GET /vAppTemplate/{id}/shadowVms", dependsOnMethods = { "testRelocateVAppTemplate" }) - public void testGetShadowVms() { - References references = vAppTemplateApi.getShadowVms(vAppTemplateURI); - - Checks.checkReferences(references); - } - - // This failed previously, but is passing now. + // This failed previously, but is passing now. // However, it's not part of the official API so not necessary to assert it. - @Test(description = "test completed task not included in vAppTemplate") + @Test(description = "test completed task not included in vAppTemplate") public void testCompletedTaskNotIncludedInVAppTemplate() throws Exception { // Kick off a task, and wait for it to complete - vAppTemplateApi.disableDownload(vAppTemplateURI); - final Task task = vAppTemplateApi.enableDownload(vAppTemplateURI); + vAppTemplateApi.disableDownload(vAppTemplateUrn); + final Task task = vAppTemplateApi.enableDownload(vAppTemplateUrn); assertTaskDoneEventually(task); // Ask the VAppTemplate for its tasks, and the status of the matching task if it exists - VAppTemplate vAppTemplate = vAppTemplateApi.getVAppTemplate(vAppTemplateURI); + VAppTemplate vAppTemplate = vAppTemplateApi.get(vAppTemplateUrn); List tasks = vAppTemplate.getTasks(); for (Task contender : tasks) { if (task.getId().equals(contender.getId())) { Task.Status status = contender.getStatus(); if (EnumSet.of(Task.Status.QUEUED, Task.Status.PRE_RUNNING, Task.Status.RUNNING).contains(status)) { - fail("Task "+contender+" reported complete, but is included in VAppTemplate in status "+status); + fail("Task " + contender + " reported complete, but is included in VAppTemplate in status " + status); } } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcApiExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcApiExpectTest.java index 937d796b22..c5d02f62e7 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcApiExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcApiExpectTest.java @@ -355,7 +355,7 @@ public class VdcApiExpectTest extends VCloudDirectorAdminApiExpectTest { Metadata expected = metadata(); - assertEquals(api.getVdcApi().getMetadataApi().get(vdcUri), expected); + assertEquals(api.getVdcApi().getMetadataApi(vdcUri).get(), expected); } @Test(enabled = false) @@ -373,7 +373,7 @@ public class VdcApiExpectTest extends VCloudDirectorAdminApiExpectTest { MetadataValue expected = metadataValue(); - assertEquals(api.getVdcApi().getMetadataApi().getValue(vdcUri, "key"), expected); + assertEquals(api.getVdcApi().getMetadataApi(vdcUri).getValue("key"), expected); } public static Vdc getVdc() { diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcApiLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcApiLiveTest.java index c6b6e7bcc5..a03552af58 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcApiLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VdcApiLiveTest.java @@ -64,7 +64,7 @@ import com.google.common.collect.Iterables; /** * Tests behavior of {@link VdcApi} * - * @author danikov + * @author danikov, Adrian Cole */ @Test(groups = { "live", "user" }, singleThreaded = true, testName = "VdcApiLiveTest") public class VdcApiLiveTest extends BaseVCloudDirectorApiLiveTest { @@ -121,7 +121,7 @@ public class VdcApiLiveTest extends BaseVCloudDirectorApiLiveTest { if (metadataSet) { try { - Task remove = adminContext.getApi().getVdcApi().getMetadataApi().removeEntry(lazyGetVdc().getHref(), "key"); + Task remove = adminContext.getApi().getVdcApi().getMetadataApi(vdcUrn).removeEntry("key"); taskDoneEventually(remove); } catch (Exception e) { logger.warn(e, "Error deleting metadata entry"); @@ -187,8 +187,8 @@ public class VdcApiLiveTest extends BaseVCloudDirectorApiLiveTest { @Test(description = "POST /vdc/{id}/action/cloneVAppTemplate") public void testCloneVAppTemplate() { - clonedVAppTemplate = vdcApi.cloneVAppTemplate(vdcUrn, CloneVAppTemplateParams.builder().source(vAppTemplateURI) - .build()); + clonedVAppTemplate = vdcApi.cloneVAppTemplate(vdcUrn, + CloneVAppTemplateParams.builder().source(lazyGetVAppTemplate().getHref()).build()); Task task = Iterables.getFirst(clonedVAppTemplate.getTasks(), null); assertNotNull(task, "vdcApi.cloneVAppTemplate returned VAppTemplate that did not contain any tasks"); @@ -259,7 +259,7 @@ public class VdcApiLiveTest extends BaseVCloudDirectorApiLiveTest { InstantiateVAppTemplateParams instantiate = InstantiateVAppTemplateParams.builder().name(name("test-vapp-")) .notDeploy().notPowerOn().description("Test VApp").instantiationParams(instantiationParams) - .source(vAppTemplateURI).build(); + .source(lazyGetVAppTemplate().getHref()).build(); instantiatedVApp = vdcApi.instantiateVApp(vdcUrn, instantiate); Task instantiationTask = Iterables.getFirst(instantiatedVApp.getTasks(), null); @@ -300,8 +300,8 @@ public class VdcApiLiveTest extends BaseVCloudDirectorApiLiveTest { } private void setupMetadata() { - adminContext.getApi().getVdcApi().getMetadataApi() - .putEntry(lazyGetVdc().getHref(), "key", MetadataValue.builder().value("value").build()); + adminContext.getApi().getVdcApi().getMetadataApi(vdcUrn) + .putEntry("key", MetadataValue.builder().value("value").build()); metadataSet = true; } @@ -311,7 +311,7 @@ public class VdcApiLiveTest extends BaseVCloudDirectorApiLiveTest { setupMetadata(); } - Metadata metadata = vdcApi.getMetadataApi().get(lazyGetVdc().getHref()); + Metadata metadata = vdcApi.getMetadataApi(vdcUrn).get(); // required for testing assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()), @@ -323,12 +323,12 @@ public class VdcApiLiveTest extends BaseVCloudDirectorApiLiveTest { @Test(description = "GET /vdc/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadata" }) public void testGetMetadataValue() { // First find a key - Metadata metadata = vdcApi.getMetadataApi().get(lazyGetVdc().getHref()); + Metadata metadata = vdcApi.getMetadataApi(vdcUrn).get(); Map metadataMap = Checks.metadataToMap(metadata); String key = Iterables.getFirst(metadataMap.keySet(), "MadeUpKey!"); String value = metadataMap.get(key); - MetadataValue metadataValue = vdcApi.getMetadataApi().getValue(lazyGetVdc().getHref(), key); + MetadataValue metadataValue = vdcApi.getMetadataApi(vdcUrn).getValue(key); Checks.checkMetadataValueFor(VDC, metadataValue, value); } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VmApiExpectTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VmApiExpectTest.java index 3bbd4eaddd..f243c598ed 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VmApiExpectTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VmApiExpectTest.java @@ -985,7 +985,7 @@ public class VmApiExpectTest extends VCloudDirectorAdminApiExpectTest { return task; } - public static ControlAccessParams getControlAccessParams() { + public static ControlAccessParams getAccessControlParams() { ControlAccessParams params = ControlAccessParams.builder() .build(); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VmApiLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VmApiLiveTest.java index c9c2ba7872..6798937fc1 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VmApiLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/VmApiLiveTest.java @@ -53,7 +53,6 @@ import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.math.BigInteger; -import java.net.URI; import java.util.List; import java.util.Map; import java.util.Set; @@ -180,12 +179,12 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { } /** - * @see VmApi#get(URI) + * @see VmApi#get(String) */ @Test(description = "GET /vApp/{id}") public void testGetVm() { // The method under test - vm = vmApi.get(vmURI); + vm = vmApi.get(vmUrn); // Check the retrieved object is well formed checkVm(vm); @@ -195,22 +194,22 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { String.format(OBJ_FIELD_EQ, VM, "deployed", "FALSE", vm.isDeployed().toString())); // Check status - assertVmStatus(vm.getHref(), Status.POWERED_OFF); + assertVmStatus(vmUrn, Status.POWERED_OFF); } /** - * @see VmApi#edit(URI, Vm) + * @see VmApi#edit(String, Vm) */ @Test(description = "PUT /vApp/{id}", dependsOnMethods = { "testGetVm" }) public void testEditVm() { Vm newVm = Vm.builder().name(name("new-name-")).description("New Description").build(); // The method under test - Task editVm = vmApi.edit(vm.getHref(), newVm); + Task editVm = vmApi.edit(vmUrn, newVm); assertTrue(retryTaskSuccess.apply(editVm), String.format(TASK_COMPLETE_TIMELY, "editVm")); // Get the edited Vm - vm = vmApi.get(vm.getHref()); + vm = vmApi.get(vmUrn); // Check the required fields are set assertEquals(vm.getName(), newVm.getName(), @@ -226,155 +225,155 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { .notPowerOn().build(); // The method under test - Task deployVm = vmApi.deploy(vm.getHref(), params); + Task deployVm = vmApi.deploy(vmUrn, params); assertTrue(retryTaskSuccessLong.apply(deployVm), String.format(TASK_COMPLETE_TIMELY, "deployVm")); // Get the edited Vm - vm = vmApi.get(vm.getHref()); + vm = vmApi.get(vmUrn); // Check the required fields are set assertTrue(vm.isDeployed(), String.format(OBJ_FIELD_EQ, VM, "deployed", "TRUE", vm.isDeployed().toString())); // Check status - assertVmStatus(vmURI, Status.POWERED_OFF); + assertVmStatus(vmUrn, Status.POWERED_OFF); } @Test(description = "POST /vApp/{id}/power/action/powerOn", dependsOnMethods = { "testDeployVm" }) public void testPowerOnVm() { // Power off Vm - vm = powerOffVm(vm.getHref()); + vm = powerOffVm(vmUrn); // The method under test - Task powerOnVm = vmApi.powerOn(vm.getHref()); + Task powerOnVm = vmApi.powerOn(vmUrn); assertTaskSucceedsLong(powerOnVm); // Get the edited Vm - vm = vmApi.get(vm.getHref()); + vm = vmApi.get(vmUrn); // Check status - assertVmStatus(vm.getHref(), Status.POWERED_ON); + assertVmStatus(vmUrn, Status.POWERED_ON); } @Test(description = "POST /vApp/{id}/power/action/reboot", dependsOnMethods = { "testDeployVm" }) public void testReboot() { // Power on Vm - vm = powerOnVm(vm.getHref()); + vm = powerOnVm(vmUrn); // The method under test - Task reboot = vmApi.reboot(vm.getHref()); + Task reboot = vmApi.reboot(vmUrn); assertTaskSucceedsLong(reboot); // Get the edited Vm - vm = vmApi.get(vm.getHref()); + vm = vmApi.get(vmUrn); // Check status - assertVmStatus(vmURI, Status.POWERED_OFF); + assertVmStatus(vmUrn, Status.POWERED_OFF); } @Test(description = "POST /vApp/{id}/power/action/shutdown", dependsOnMethods = { "testInstallVMwareTools" }) public void testShutdown() { // Power on Vm - vm = powerOnVm(vm.getHref()); + vm = powerOnVm(vmUrn); // The method under test - Task shutdown = vmApi.shutdown(vm.getHref()); + Task shutdown = vmApi.shutdown(vmUrn); assertTaskSucceedsLong(shutdown); // Get the edited Vm - vm = vmApi.get(vm.getHref()); + vm = vmApi.get(vmUrn); // Check status - assertVmStatus(vm.getHref(), Status.POWERED_OFF); + assertVmStatus(vmUrn, Status.POWERED_OFF); } @Test(description = "POST /vApp/{id}/power/action/suspend", dependsOnMethods = { "testDeployVm" }) public void testSuspend() { // Power on Vm - vm = powerOnVm(vm.getHref()); + vm = powerOnVm(vmUrn); // The method under test - Task suspend = vmApi.suspend(vmURI); + Task suspend = vmApi.suspend(vmUrn); assertTaskSucceedsLong(suspend); // Get the edited Vm - vm = vmApi.get(vm.getHref()); + vm = vmApi.get(vmUrn); // Check status - assertVmStatus(vmURI, Status.SUSPENDED); + assertVmStatus(vmUrn, Status.SUSPENDED); // Power on the Vm again - vm = powerOnVm(vm.getHref()); + vm = powerOnVm(vmUrn); } @Test(description = "POST /vApp/{id}/power/action/reset", dependsOnMethods = { "testDeployVm" }) public void testReset() { // Power on Vm - vm = powerOnVm(vm.getHref()); + vm = powerOnVm(vmUrn); // The method under test - Task reset = vmApi.reset(vmURI); + Task reset = vmApi.reset(vmUrn); assertTaskSucceedsLong(reset); // Get the edited Vm - vm = vmApi.get(vm.getHref()); + vm = vmApi.get(vmUrn); // Check status - assertVmStatus(vmURI, Status.POWERED_ON); + assertVmStatus(vmUrn, Status.POWERED_ON); } @Test(description = "POST /vApp/{id}/action/undeploy", dependsOnMethods = { "testDeployVm" }) public void testUndeployVm() { // Power on Vm - vm = powerOnVm(vm.getHref()); + vm = powerOnVm(vmUrn); UndeployVAppParams params = UndeployVAppParams.builder().build(); // The method under test - Task undeploy = vmApi.undeploy(vm.getHref(), params); + Task undeploy = vmApi.undeploy(vmUrn, params); assertTrue(retryTaskSuccess.apply(undeploy), String.format(TASK_COMPLETE_TIMELY, "undeploy")); // Get the edited Vm - vm = vmApi.get(vm.getHref()); + vm = vmApi.get(vmUrn); // Check status assertFalse(vm.isDeployed(), String.format(OBJ_FIELD_EQ, VM, "deployed", "FALSE", vm.isDeployed().toString())); - assertVmStatus(vmURI, Status.POWERED_OFF); + assertVmStatus(vmUrn, Status.POWERED_OFF); } @Test(description = "POST /vApp/{id}/power/action/powerOff", dependsOnMethods = { "testUndeployVm" }) public void testPowerOffVm() { // Power on Vm - vm = powerOnVm(vm.getHref()); + vm = powerOnVm(vmUrn); // The method under test // NB this will put the vm in partially powered off state - Task powerOffVm = vmApi.powerOff(vm.getHref()); + Task powerOffVm = vmApi.powerOff(vmUrn); assertTrue(retryTaskSuccess.apply(powerOffVm), String.format(TASK_COMPLETE_TIMELY, "powerOffVm")); // Get the edited Vm - vm = vmApi.get(vmURI); + vm = vmApi.get(vmUrn); // Check status - assertVmStatus(vmURI, Status.POWERED_OFF); + assertVmStatus(vmUrn, Status.POWERED_OFF); } @Test(description = "POST /vApp/{id}/action/consolidate", dependsOnMethods = { "testDeployVm" }) public void testConsolidateVm() { // Power on Vm - vm = powerOnVm(vm.getHref()); + vm = powerOnVm(vmUrn); // The method under test - Task consolidateVm = vmApi.consolidate(vm.getHref()); + Task consolidateVm = vmApi.consolidate(vmUrn); assertTrue(retryTaskSuccess.apply(consolidateVm), String.format(TASK_COMPLETE_TIMELY, "consolidateVm")); } @Test(description = "POST /vApp/{id}/action/discardSuspendedState", dependsOnMethods = { "testDeployVm" }) public void testDiscardSuspendedState() { // Suspend the Vm - vm = suspendVm(vm.getHref()); + vm = suspendVm(vmUrn); // The method under test - Task discardSuspendedState = vmApi.discardSuspendedState(vm.getHref()); + Task discardSuspendedState = vmApi.discardSuspendedState(vmUrn); assertTrue(retryTaskSuccess.apply(discardSuspendedState), String.format(TASK_COMPLETE_TIMELY, "discardSuspendedState")); } @@ -382,10 +381,10 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "POST /vApp/{id}/action/installVMwareTools", dependsOnMethods = { "testDeployVm" }) public void testInstallVMwareTools() { // First ensure the vApp is powered on - vm = powerOnVm(vm.getHref()); + vm = powerOnVm(vmUrn); // The method under test - Task installVMwareTools = vmApi.installVMwareTools(vm.getHref()); + Task installVMwareTools = vmApi.installVMwareTools(vmUrn); assertTrue(retryTaskSuccess.apply(installVMwareTools), String.format(TASK_COMPLETE_TIMELY, "installVMwareTools")); } @@ -399,29 +398,29 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { .build(); // The method under test - Task relocate = vmApi.relocate(vm.getHref(), params); + Task relocate = vmApi.relocate(vmUrn, params); assertTrue(retryTaskSuccess.apply(relocate), String.format(TASK_COMPLETE_TIMELY, "relocate")); } @Test(description = "POST /vApp/{id}/action/upgradeHardwareVersion", dependsOnMethods = { "testGetVm" }) public void testUpgradeHardwareVersion() { // Power off Vm - vm = powerOffVm(vm.getHref()); + vm = powerOffVm(vmUrn); // The method under test - Task upgradeHardwareVersion = vmApi.upgradeHardwareVersion(vm.getHref()); + Task upgradeHardwareVersion = vmApi.upgradeHardwareVersion(vmUrn); assertTrue(retryTaskSuccess.apply(upgradeHardwareVersion), String.format(TASK_COMPLETE_TIMELY, "upgradeHardwareVersion")); // Power on the Vm again - vm = powerOnVm(vm.getHref()); + vm = powerOnVm(vmUrn); } @Test(description = "GET /vApp/{id}/guestCustomizationSection", dependsOnMethods = { "testGetVm" }) public void testGetGuestCustomizationSection() { - getGuestCustomizationSection(new Function() { + getGuestCustomizationSection(new Function() { @Override - public GuestCustomizationSection apply(URI uri) { + public GuestCustomizationSection apply(String uri) { return vmApi.getGuestCustomizationSection(uri); } }); @@ -430,18 +429,18 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "PUT /vApp/{id}/guestCustomizationSection", dependsOnMethods = { "testGetGuestCustomizationSection" }) public void testEditGuestCustomizationSection() { // Copy existing section and edit fields - GuestCustomizationSection oldSection = vmApi.getGuestCustomizationSection(vm.getHref()); + GuestCustomizationSection oldSection = vmApi.getGuestCustomizationSection(vmUrn); GuestCustomizationSection newSection = oldSection.toBuilder().computerName(name("n")).enabled(Boolean.TRUE) .adminPassword(null) // Not allowed .build(); // The method under test - Task editGuestCustomizationSection = vmApi.editGuestCustomizationSection(vm.getHref(), newSection); + Task editGuestCustomizationSection = vmApi.editGuestCustomizationSection(vmUrn, newSection); assertTrue(retryTaskSuccess.apply(editGuestCustomizationSection), String.format(TASK_COMPLETE_TIMELY, "editGuestCustomizationSection")); // Retrieve the modified section - GuestCustomizationSection modified = vmApi.getGuestCustomizationSection(vm.getHref()); + GuestCustomizationSection modified = vmApi.getGuestCustomizationSection(vmUrn); // Check the retrieved object is well formed checkGuestCustomizationSection(modified); @@ -466,7 +465,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { .media(Reference.builder().href(mediaURI).type(MEDIA).build()).build(); // The method under test - Task insertMedia = vmApi.insertMedia(vm.getHref(), params); + Task insertMedia = vmApi.insertMedia(vmUrn, params); assertTrue(retryTaskSuccess.apply(insertMedia), String.format(TASK_COMPLETE_TIMELY, "insertMedia")); } @@ -477,15 +476,15 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { .media(Reference.builder().href(mediaURI).type(MEDIA).build()).build(); // The method under test - Task ejectMedia = vmApi.ejectMedia(vm.getHref(), params); + Task ejectMedia = vmApi.ejectMedia(vmUrn, params); assertTrue(retryTaskSuccess.apply(ejectMedia), String.format(TASK_COMPLETE_TIMELY, "ejectMedia")); } @Test(description = "GET /vApp/{id}/networkConnectionSection", dependsOnMethods = { "testGetVm" }) public void testGetNetworkConnectionSection() { - getNetworkConnectionSection(new Function() { + getNetworkConnectionSection(new Function() { @Override - public NetworkConnectionSection apply(URI uri) { + public NetworkConnectionSection apply(String uri) { return vmApi.getNetworkConnectionSection(uri); } }); @@ -494,13 +493,13 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { // FIXME "Task error: Unable to perform this action. Contact your cloud administrator." @Test(description = "PUT /vApp/{id}/networkConnectionSection", dependsOnMethods = { "testEditGuestCustomizationSection" }) public void testEditNetworkConnectionSection() { - powerOffVm(vm.getHref()); + powerOffVm(vmUrn); // Look up a network in the Vdc Set networks = vdc.getAvailableNetworks(); Reference network = Iterables.getLast(networks); // Copy existing section and edit fields - NetworkConnectionSection oldSection = vmApi.getNetworkConnectionSection(vm.getHref()); + NetworkConnectionSection oldSection = vmApi.getNetworkConnectionSection(vmUrn); NetworkConnectionSection newSection = oldSection .toBuilder() .networkConnection( @@ -508,12 +507,12 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { .network(network.getName()).build()).build(); // The method under test - Task editNetworkConnectionSection = vmApi.editNetworkConnectionSection(vm.getHref(), newSection); + Task editNetworkConnectionSection = vmApi.editNetworkConnectionSection(vmUrn, newSection); assertTrue(retryTaskSuccess.apply(editNetworkConnectionSection), String.format(TASK_COMPLETE_TIMELY, "editNetworkConnectionSection")); // Retrieve the modified section - NetworkConnectionSection modified = vmApi.getNetworkConnectionSection(vm.getHref()); + NetworkConnectionSection modified = vmApi.getNetworkConnectionSection(vmUrn); // Check the retrieved object is well formed checkNetworkConnectionSection(modified); @@ -528,7 +527,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "GET /vApp/{id}/operatingSystemSection", dependsOnMethods = { "testGetVm" }) public void testGetOperatingSystemSection() { // The method under test - OperatingSystemSection section = vmApi.getOperatingSystemSection(vm.getHref()); + OperatingSystemSection section = vmApi.getOperatingSystemSection(vmUrn); // Check the retrieved object is well formed checkOperatingSystemSection(section); @@ -544,12 +543,12 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { .id(OSType.RHEL_64.getCode()).osType("rhel5_64Guest").build(); // The method under test - Task editOperatingSystemSection = vmApi.editOperatingSystemSection(vm.getHref(), newSection); + Task editOperatingSystemSection = vmApi.editOperatingSystemSection(vmUrn, newSection); assertTrue(retryTaskSuccess.apply(editOperatingSystemSection), String.format(TASK_COMPLETE_TIMELY, "editOperatingSystemSection")); // Retrieve the modified section - OperatingSystemSection modified = vmApi.getOperatingSystemSection(vm.getHref()); + OperatingSystemSection modified = vmApi.getOperatingSystemSection(vmUrn); // Check the retrieved object is well formed checkOperatingSystemSection(modified); @@ -561,7 +560,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "GET /vApp/{id}/productSections", dependsOnMethods = { "testGetVm" }) public void testGetProductSections() { // The method under test - ProductSectionList sectionList = vmApi.getProductSections(vm.getHref()); + ProductSectionList sectionList = vmApi.getProductSections(vmUrn); // Check the retrieved object is well formed checkProductSectionList(sectionList); @@ -569,9 +568,9 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "PUT /vApp/{id}/productSections", dependsOnMethods = { "testGetProductSections" }) public void testEditProductSections() { - powerOffVm(vm.getHref()); + powerOffVm(vmUrn); // Copy existing section and edit fields - ProductSectionList oldSections = vmApi.getProductSections(vm.getHref()); + ProductSectionList oldSections = vmApi.getProductSections(vmUrn); ProductSectionList newSections = oldSections .toBuilder() .productSection( @@ -583,12 +582,12 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { .build()).build(); // The method under test - Task editProductSections = vmApi.editProductSections(vm.getHref(), newSections); + Task editProductSections = vmApi.editProductSections(vmUrn, newSections); assertTrue(retryTaskSuccess.apply(editProductSections), String.format(TASK_COMPLETE_TIMELY, "editProductSections")); // Retrieve the modified section - ProductSectionList modified = vmApi.getProductSections(vm.getHref()); + ProductSectionList modified = vmApi.getProductSections(vmUrn); // Check the retrieved object is well formed checkProductSectionList(modified); @@ -604,12 +603,12 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "GET /vApp/{id}/question", dependsOnMethods = { "testDeployVm" }) public void testGetPendingQuestion() { // Power on Vm - vm = powerOnVm(vm.getHref()); + vm = powerOnVm(vmUrn); // TODO how to test? // The method under test - VmPendingQuestion question = vmApi.getPendingQuestion(vm.getHref()); + VmPendingQuestion question = vmApi.getPendingQuestion(vmUrn); // Check the retrieved object is well formed checkVmPendingQuestion(question); @@ -620,7 +619,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { // TODO check that the question has been answered (e.g. asking for getPendingQuestion does not // include our answered question). - VmPendingQuestion question = vmApi.getPendingQuestion(vm.getHref()); + VmPendingQuestion question = vmApi.getPendingQuestion(vmUrn); List answerChoices = question.getChoices(); VmQuestionAnswerChoice answerChoice = Iterables.getFirst(answerChoices, null); assertNotNull(answerChoice, "Question " + question + " must have at least once answer-choice"); @@ -628,13 +627,13 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { VmQuestionAnswer answer = VmQuestionAnswer.builder().choiceId(answerChoice.getId()) .questionId(question.getQuestionId()).build(); - vmApi.answerQuestion(vm.getHref(), answer); + vmApi.answerQuestion(vmUrn, answer); } @Test(description = "GET /vApp/{id}/runtimeInfoSection", dependsOnMethods = { "testGetVm" }) public void testGetRuntimeInfoSection() { // The method under test - RuntimeInfoSection section = vmApi.getRuntimeInfoSection(vm.getHref()); + RuntimeInfoSection section = vmApi.getRuntimeInfoSection(vmUrn); // Check the retrieved object is well formed checkRuntimeInfoSection(section); @@ -644,10 +643,10 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "GET /vApp/{id}/screen", dependsOnMethods = { "testInstallVMwareTools" }) public void testGetScreenImage() { // Power on Vm - vm = powerOnVm(vm.getHref()); + vm = powerOnVm(vmUrn); // The method under test - byte[] image = vmApi.getScreenImage(vm.getHref()); + byte[] image = vmApi.getScreenImage(vmUrn); // Check returned bytes against PNG header magic number byte[] pngHeaderBytes = new byte[] { (byte) 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A }; @@ -662,10 +661,10 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "POST /vApp/{id}/screen/action/acquireTicket", dependsOnMethods = { "testDeployVm" }) public void testGetScreenTicket() { // Power on Vm - vm = powerOnVm(vm.getHref()); + vm = powerOnVm(vmUrn); // The method under test - ScreenTicket ticket = vmApi.getScreenTicket(vm.getHref()); + ScreenTicket ticket = vmApi.getScreenTicket(vmUrn); // Check the retrieved object is well formed checkScreenTicket(ticket); @@ -674,7 +673,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "GET /vApp/{id}/virtualHardwareSection", dependsOnMethods = { "testGetVm" }) public void testGetVirtualHardwareSection() { // Method under test - VirtualHardwareSection hardware = vmApi.getVirtualHardwareSection(vm.getHref()); + VirtualHardwareSection hardware = vmApi.getVirtualHardwareSection(vmUrn); // Check the retrieved object is well formed checkVirtualHardwareSection(hardware); @@ -683,10 +682,10 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "PUT /vApp/{id}/virtualHardwareSection", dependsOnMethods = { "testGetVirtualHardwareSection" }) public void testEditVirtualHardwareSection() { // Power off Vm - vm = powerOffVm(vm.getHref()); + vm = powerOffVm(vmUrn); // Copy existing section and edit fields - VirtualHardwareSection oldSection = vmApi.getVirtualHardwareSection(vm.getHref()); + VirtualHardwareSection oldSection = vmApi.getVirtualHardwareSection(vmUrn); Set oldItems = oldSection.getItems(); Set newItems = Sets.newLinkedHashSet(oldItems); ResourceAllocationSettingData oldMemory = Iterables.find(oldItems, @@ -703,12 +702,12 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { VirtualHardwareSection newSection = oldSection.toBuilder().items(newItems).build(); // The method under test - Task editVirtualHardwareSection = vmApi.editVirtualHardwareSection(vm.getHref(), newSection); + Task editVirtualHardwareSection = vmApi.editVirtualHardwareSection(vmUrn, newSection); assertTrue(retryTaskSuccess.apply(editVirtualHardwareSection), String.format(TASK_COMPLETE_TIMELY, "editVirtualHardwareSection")); // Retrieve the modified section - VirtualHardwareSection modifiedSection = vmApi.getVirtualHardwareSection(vm.getHref()); + VirtualHardwareSection modifiedSection = vmApi.getVirtualHardwareSection(vmUrn); // Check the retrieved object is well formed checkVirtualHardwareSection(modifiedSection); @@ -729,7 +728,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "GET /vApp/{id}/virtualHardwareSection/cpu", dependsOnMethods = { "testGetVirtualHardwareSection" }) public void testGetVirtualHardwareSectionCpu() { // Method under test - RasdItem rasd = vmApi.getVirtualHardwareSectionCpu(vm.getHref()); + RasdItem rasd = vmApi.getVirtualHardwareSectionCpu(vmUrn); // Check the retrieved object is well formed checkResourceAllocationSettingData(rasd); @@ -738,17 +737,17 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "PUT /vApp/{id}/virtualHardwareSection/cpu", dependsOnMethods = { "testGetVirtualHardwareSectionCpu" }) public void testEditVirtualHardwareSectionCpu() { // Copy existing section and edit fields - RasdItem oldItem = vmApi.getVirtualHardwareSectionCpu(vm.getHref()); + RasdItem oldItem = vmApi.getVirtualHardwareSectionCpu(vmUrn); RasdItem newItem = oldItem.toBuilder().elementName("2 virtual CPU(s)").virtualQuantity(new BigInteger("2")) .build(); // Method under test - Task editVirtualHardwareSectionCpu = vmApi.editVirtualHardwareSectionCpu(vm.getHref(), newItem); + Task editVirtualHardwareSectionCpu = vmApi.editVirtualHardwareSectionCpu(vmUrn, newItem); assertTrue(retryTaskSuccess.apply(editVirtualHardwareSectionCpu), String.format(TASK_COMPLETE_TIMELY, "editVirtualHardwareSectionCpu")); // Retrieve the modified section - RasdItem modified = vmApi.getVirtualHardwareSectionCpu(vm.getHref()); + RasdItem modified = vmApi.getVirtualHardwareSectionCpu(vmUrn); // Check the retrieved object checkResourceAllocationSettingData(modified); @@ -762,7 +761,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "GET /vApp/{id}/virtualHardwareSection/disks", dependsOnMethods = { "testGetVirtualHardwareSection" }) public void testGetVirtualHardwareSectionDisks() { // Method under test - RasdItemsList rasdItems = vmApi.getVirtualHardwareSectionDisks(vm.getHref()); + RasdItemsList rasdItems = vmApi.getVirtualHardwareSectionDisks(vmUrn); // Check the retrieved object is well formed checkRasdItemsList(rasdItems); @@ -771,16 +770,16 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "PUT /vApp/{id}/virtualHardwareSection/disks", dependsOnMethods = { "testGetVirtualHardwareSectionDisks" }) public void testEditVirtualHardwareSectionDisks() { // Copy the existing items list and edit the name of an item - RasdItemsList oldSection = vmApi.getVirtualHardwareSectionDisks(vm.getHref()); + RasdItemsList oldSection = vmApi.getVirtualHardwareSectionDisks(vmUrn); RasdItemsList newSection = oldSection.toBuilder().build(); // Method under test - Task editVirtualHardwareSectionDisks = vmApi.editVirtualHardwareSectionDisks(vm.getHref(), newSection); + Task editVirtualHardwareSectionDisks = vmApi.editVirtualHardwareSectionDisks(vmUrn, newSection); assertTrue(retryTaskSuccess.apply(editVirtualHardwareSectionDisks), String.format(TASK_COMPLETE_TIMELY, "editVirtualHardwareSectionDisks")); // Retrieve the modified section - RasdItemsList modified = vmApi.getVirtualHardwareSectionDisks(vm.getHref()); + RasdItemsList modified = vmApi.getVirtualHardwareSectionDisks(vmUrn); // Check the retrieved object is well formed checkRasdItemsList(modified); @@ -812,7 +811,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "GET /vApp/{id}/virtualHardwareSection/media", dependsOnMethods = { "testGetVirtualHardwareSection" }) public void testGetVirtualHardwareSectionMedia() { // Method under test - RasdItemsList rasdItems = vmApi.getVirtualHardwareSectionMedia(vm.getHref()); + RasdItemsList rasdItems = vmApi.getVirtualHardwareSectionMedia(vmUrn); // Check the retrieved object is well formed checkRasdItemsList(rasdItems); @@ -821,7 +820,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "GET /vApp/{id}/virtualHardwareSection/memory", dependsOnMethods = { "testGetVirtualHardwareSection" }) public void testGetVirtualHardwareSectionMemory() { // Method under test - RasdItem rasd = vmApi.getVirtualHardwareSectionCpu(vm.getHref()); + RasdItem rasd = vmApi.getVirtualHardwareSectionCpu(vmUrn); // Check the retrieved object is well formed checkResourceAllocationSettingData(rasd); @@ -829,17 +828,17 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "PUT /vApp/{id}/virtualHardwareSection/memory", dependsOnMethods = { "testGetVirtualHardwareSectionMemory" }) public void testEditVirtualHardwareSectionMemory() { - RasdItem origItem = vmApi.getVirtualHardwareSectionMemory(vm.getHref()); + RasdItem origItem = vmApi.getVirtualHardwareSectionMemory(vmUrn); RasdItem newItem = origItem.toBuilder().elementName("1024 MB of memory").virtualQuantity(new BigInteger("1024")) .build(); // Method under test - Task editVirtualHardwareSectionMemory = vmApi.editVirtualHardwareSectionMemory(vm.getHref(), newItem); + Task editVirtualHardwareSectionMemory = vmApi.editVirtualHardwareSectionMemory(vmUrn, newItem); assertTrue(retryTaskSuccess.apply(editVirtualHardwareSectionMemory), String.format(TASK_COMPLETE_TIMELY, "editVirtualHardwareSectionMemory")); // Retrieve the modified section - RasdItem modified = vmApi.getVirtualHardwareSectionMemory(vm.getHref()); + RasdItem modified = vmApi.getVirtualHardwareSectionMemory(vmUrn); // Check the retrieved object checkResourceAllocationSettingData(modified); @@ -853,7 +852,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "GET /vApp/{id}/virtualHardwareSection/networkCards", dependsOnMethods = { "testGetVirtualHardwareSection" }) public void testGetVirtualHardwareSectionNetworkCards() { // Method under test - RasdItemsList rasdItems = vmApi.getVirtualHardwareSectionNetworkCards(vm.getHref()); + RasdItemsList rasdItems = vmApi.getVirtualHardwareSectionNetworkCards(vmUrn); // Check the retrieved object is well formed checkRasdItemsList(rasdItems); @@ -861,17 +860,17 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "PUT /vApp/{id}/virtualHardwareSection/networkCards", dependsOnMethods = { "testGetVirtualHardwareSectionNetworkCards" }) public void testEditVirtualHardwareSectionNetworkCards() { - RasdItemsList oldSection = vmApi.getVirtualHardwareSectionNetworkCards(vm.getHref()); + RasdItemsList oldSection = vmApi.getVirtualHardwareSectionNetworkCards(vmUrn); RasdItemsList newSection = oldSection.toBuilder().build(); // Method under test - Task editVirtualHardwareSectionNetworkCards = vmApi.editVirtualHardwareSectionNetworkCards(vm.getHref(), + Task editVirtualHardwareSectionNetworkCards = vmApi.editVirtualHardwareSectionNetworkCards(vmUrn, newSection); assertTrue(retryTaskSuccess.apply(editVirtualHardwareSectionNetworkCards), String.format(TASK_COMPLETE_TIMELY, "editVirtualHardwareSectionNetworkCards")); // Retrieve the modified section - RasdItemsList modified = vmApi.getVirtualHardwareSectionNetworkCards(vm.getHref()); + RasdItemsList modified = vmApi.getVirtualHardwareSectionNetworkCards(vmUrn); // Check the retrieved object is well formed checkRasdItemsList(modified); @@ -885,7 +884,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "GET /vApp/{id}/virtualHardwareSection/serialPorts", dependsOnMethods = { "testGetVirtualHardwareSection" }) public void testGetVirtualHardwareSectionSerialPorts() { // Method under test - RasdItemsList rasdItems = vmApi.getVirtualHardwareSectionSerialPorts(vm.getHref()); + RasdItemsList rasdItems = vmApi.getVirtualHardwareSectionSerialPorts(vmUrn); // Check the retrieved object is well formed checkRasdItemsList(rasdItems); @@ -893,17 +892,17 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "PUT /vApp/{id}/virtualHardwareSection/serialPorts", dependsOnMethods = { "testGetVirtualHardwareSectionSerialPorts" }) public void testEditVirtualHardwareSectionSerialPorts() { - RasdItemsList oldSection = vmApi.getVirtualHardwareSectionSerialPorts(vm.getHref()); + RasdItemsList oldSection = vmApi.getVirtualHardwareSectionSerialPorts(vmUrn); RasdItemsList newSection = oldSection.toBuilder().build(); // Method under test Task editVirtualHardwareSectionSerialPorts = vmApi - .editVirtualHardwareSectionSerialPorts(vm.getHref(), newSection); + .editVirtualHardwareSectionSerialPorts(vmUrn, newSection); assertTrue(retryTaskSuccess.apply(editVirtualHardwareSectionSerialPorts), String.format(TASK_COMPLETE_TIMELY, "editVirtualHardwareSectionSerialPorts")); // Retrieve the modified section - RasdItemsList modified = vmApi.getVirtualHardwareSectionSerialPorts(vm.getHref()); + RasdItemsList modified = vmApi.getVirtualHardwareSectionSerialPorts(vmUrn); // Check the retrieved object is well formed checkRasdItemsList(modified); @@ -919,10 +918,10 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { key = name("key-"); String value = name("value-"); metadataValue = MetadataValue.builder().value(value).build(); - vmApi.getMetadataApi().putEntry(vm.getHref(), key, metadataValue); + vmApi.getMetadataApi(vmUrn).putEntry(key, metadataValue); // Retrieve the value, and assert it was set correctly - MetadataValue newMetadataValue = vmApi.getMetadataApi().getValue(vm.getHref(), key); + MetadataValue newMetadataValue = vmApi.getMetadataApi(vmUrn).getValue(key); // Check the retrieved object is well formed checkMetadataValueFor(VM, newMetadataValue, value); @@ -931,7 +930,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "GET /vApp/{id}/metadata", dependsOnMethods = { "testSetMetadataValue" }) public void testGetMetadata() { // Call the method being tested - Metadata metadata = vmApi.getMetadataApi().get(vm.getHref()); + Metadata metadata = vmApi.getMetadataApi(vmUrn).get(); checkMetadata(metadata); @@ -945,10 +944,10 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { key = name("key-"); String value = name("value-"); metadataValue = MetadataValue.builder().value(value).build(); - vmApi.getMetadataApi().putEntry(vm.getHref(), key, metadataValue); + vmApi.getMetadataApi(vmUrn).putEntry(key, metadataValue); // Call the method being tested - MetadataValue metadataValue = vmApi.getMetadataApi().getValue(vm.getHref(), key); + MetadataValue metadataValue = vmApi.getMetadataApi(vmUrn).getValue(key); String expected = metadataValue.getValue(); @@ -960,11 +959,11 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "DELETE /vApp/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadataValue" }) public void testRemoveMetadataEntry() { // Delete the entry - Task task = vmApi.getMetadataApi().removeEntry(vm.getHref(), key); + Task task = vmApi.getMetadataApi(vmUrn).removeEntry(key); retryTaskSuccess.apply(task); // Confirm the entry has been removed - Metadata newMetadata = vmApi.getMetadataApi().get(vm.getHref()); + Metadata newMetadata = vmApi.getMetadataApi(vmUrn).get(); // Check the retrieved object is well formed checkMetadataKeyAbsentFor(VM, newMetadata, key); @@ -972,18 +971,18 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { @Test(description = "POST /vApp/{id}/metadata", dependsOnMethods = { "testGetMetadata" }) public void testMergeMetadata() { - Metadata oldMetadata = vmApi.getMetadataApi().get(vm.getHref()); + Metadata oldMetadata = vmApi.getMetadataApi(vmUrn).get(); Map oldMetadataMap = Checks.metadataToMap(oldMetadata); // Store a value, to be removed String key = name("key-"); String value = name("value-"); Metadata addedMetadata = Metadata.builder().entry(MetadataEntry.builder().key(key).value(value).build()).build(); - Task task = vmApi.getMetadataApi().merge(vm.getHref(), addedMetadata); + Task task = vmApi.getMetadataApi(vmUrn).merge(addedMetadata); retryTaskSuccess.apply(task); // Confirm the entry contains everything that was there, and everything that was being added - Metadata newMetadata = vmApi.getMetadataApi().get(vm.getHref()); + Metadata newMetadata = vmApi.getMetadataApi(vmUrn).get(); Map expectedMetadataMap = ImmutableMap. builder().putAll(oldMetadataMap) .put(key, value).build(); @@ -992,7 +991,7 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { } /** - * @see VmApi#remove(URI) + * @see VmApi#remove(String) */ @Test(description = "DELETE /vApp/{id}") public void testRemoveVm() { @@ -1001,27 +1000,27 @@ public class VmApiLiveTest extends AbstractVAppApiLiveTest { DeployVAppParams params = DeployVAppParams.builder() .deploymentLeaseSeconds((int) TimeUnit.SECONDS.convert(1L, TimeUnit.HOURS)).notForceCustomization() .powerOn().build(); - Task deployVApp = vAppApi.deploy(remove.getHref(), params); + Task deployVApp = vAppApi.deploy(remove.getId(), params); assertTaskSucceedsLong(deployVApp); // Get the edited VApp and the Vm - remove = vAppApi.getVApp(remove.getHref()); + remove = vAppApi.get(remove.getId()); List vms = remove.getChildren().getVms(); Vm temp = Iterables.get(vms, 0); // otherwise it's impossible to stop a running vApp with no vms if (vms.size() == 1) { UndeployVAppParams undeployParams = UndeployVAppParams.builder().build(); - Task shutdownVapp = vAppApi.undeploy(remove.getHref(), undeployParams); + Task shutdownVapp = vAppApi.undeploy(remove.getId(), undeployParams); assertTaskSucceedsLong(shutdownVapp); } else { - powerOffVm(temp.getHref()); + powerOffVm(temp.getId()); } // The method under test - Task removeVm = vmApi.remove(temp.getHref()); + Task removeVm = vmApi.remove(temp.getId()); assertTrue(retryTaskSuccess.apply(removeVm), String.format(TASK_COMPLETE_TIMELY, "removeVm")); - Vm removed = vmApi.get(temp.getHref()); + Vm removed = vmApi.get(temp.getId()); assertNull(removed, "The Vm " + temp.getName() + " should have been removed"); } } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcApiLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcApiLiveTest.java index 0ac4bc024e..8e5eeb0fdb 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcApiLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/admin/AdminVdcApiLiveTest.java @@ -60,14 +60,14 @@ public class AdminVdcApiLiveTest extends BaseVCloudDirectorApiLiveTest { @BeforeClass(alwaysRun = true) public void setupRequiredApis() { vdcApi = adminContext.getApi().getVdcApi(); - metadataApi = vdcApi.getMetadataApi(); + metadataApi = vdcApi.getMetadataApi(vdcUrn); } @AfterClass(alwaysRun = true) public void cleanUp() throws Exception { if (metadataKey != null) { try { - Task task = metadataApi.removeEntry(lazyGetVdc().getHref(), metadataKey); + Task task = metadataApi.removeEntry(metadataKey); taskDoneEventually(task); } catch (VCloudDirectorException e) { logger.warn(e, "Error deleting metadata-value (perhaps it doesn't exist?); continuing..."); @@ -161,7 +161,7 @@ public class AdminVdcApiLiveTest extends BaseVCloudDirectorApiLiveTest { @Test(description = "GET /admin/vdc/{id}/metadata") public void testGetMetadata() throws Exception { - Metadata metadata = metadataApi.get(lazyGetVdc().getHref()); + Metadata metadata = metadataApi.get(); Checks.checkMetadata(metadata); } @@ -174,10 +174,10 @@ public class AdminVdcApiLiveTest extends BaseVCloudDirectorApiLiveTest { Metadata metadata = Metadata.builder().entry(MetadataEntry.builder().entry(metadataKey, metadataValue).build()) .build(); - Task task = metadataApi.merge(lazyGetVdc().getHref(), metadata); + Task task = metadataApi.merge(metadata); assertTaskSucceeds(task); - MetadataValue modified = metadataApi.getValue(lazyGetVdc().getHref(), metadataKey); + MetadataValue modified = metadataApi.getValue(metadataKey); Checks.checkMetadataValueFor("AdminVdc", modified, metadataValue); Checks.checkMetadata(metadata); } @@ -185,7 +185,7 @@ public class AdminVdcApiLiveTest extends BaseVCloudDirectorApiLiveTest { // TODO insufficient permissions to test @Test(description = "GET /admin/vdc/{id}/metadata/{key}", dependsOnMethods = { "testSetMetadata" }, enabled = false) public void testGetMetadataValue() throws Exception { - MetadataValue retrievedMetadataValue = metadataApi.getValue(lazyGetVdc().getHref(), metadataKey); + MetadataValue retrievedMetadataValue = metadataApi.getValue(metadataKey); Checks.checkMetadataValueFor("AdminVdc", retrievedMetadataValue, metadataValue); } @@ -196,10 +196,10 @@ public class AdminVdcApiLiveTest extends BaseVCloudDirectorApiLiveTest { metadataValue = name("value-"); MetadataValue newV = MetadataValue.builder().value(metadataValue).build(); - Task task = metadataApi.putEntry(lazyGetVdc().getHref(), metadataKey, newV); + Task task = metadataApi.putEntry(metadataKey, newV); assertTaskSucceeds(task); - MetadataValue retrievedMetadataValue = metadataApi.getValue(lazyGetVdc().getHref(), metadataKey); + MetadataValue retrievedMetadataValue = metadataApi.getValue(metadataKey); Checks.checkMetadataValueFor("AdminVdc", retrievedMetadataValue, metadataValue); } @@ -208,11 +208,11 @@ public class AdminVdcApiLiveTest extends BaseVCloudDirectorApiLiveTest { public void testRemoveMetadataValue() throws Exception { // TODO Remove dependency on other tests; make cleanUp remove a list of metadata entries? - Task task = metadataApi.removeEntry(lazyGetVdc().getHref(), metadataKey); + Task task = metadataApi.removeEntry(metadataKey); assertTaskSucceeds(task); try { - metadataApi.getValue(lazyGetVdc().getHref(), metadataKey); + metadataApi.getValue(metadataKey); fail("Retrieval of metadata value " + metadataKey + " should have fail after deletion"); } catch (VCloudDirectorException e) { // success; should not be accessible diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorApiLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorApiLiveTest.java index d2e938d579..9ba93c8536 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorApiLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/internal/BaseVCloudDirectorApiLiveTest.java @@ -19,7 +19,6 @@ package org.jclouds.vcloud.director.v1_5.internal; import static com.google.common.base.Strings.emptyToNull; -import static com.google.common.collect.FluentIterable.from; import static com.google.common.collect.Iterables.any; import static com.google.common.collect.Iterables.find; import static com.google.common.collect.Iterables.getFirst; @@ -33,6 +32,7 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.NETWORK; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.ORG_NETWORK; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.USER; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.VAPP; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.VAPP_TEMPLATE; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.VDC; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; @@ -61,6 +61,7 @@ import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminApi; import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminAsyncApi; import org.jclouds.vcloud.director.v1_5.domain.Catalog; import org.jclouds.vcloud.director.v1_5.domain.Link; +import org.jclouds.vcloud.director.v1_5.domain.Link.Rel; import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.ResourceEntity.Status; import org.jclouds.vcloud.director.v1_5.domain.Role.DefaultRoles; @@ -83,7 +84,6 @@ import org.jclouds.vcloud.director.v1_5.features.TaskApi; import org.jclouds.vcloud.director.v1_5.features.VAppApi; import org.jclouds.vcloud.director.v1_5.features.VAppTemplateApi; import org.jclouds.vcloud.director.v1_5.features.VdcApi; -import org.jclouds.vcloud.director.v1_5.predicates.EntityPredicates; import org.jclouds.vcloud.director.v1_5.predicates.LinkPredicates; import org.jclouds.vcloud.director.v1_5.predicates.ReferencePredicates; import org.jclouds.vcloud.director.v1_5.predicates.TaskStatusEquals; @@ -96,10 +96,13 @@ import org.testng.annotations.Listeners; import org.testng.annotations.Test; import com.google.common.base.Function; +import com.google.common.base.Objects; import com.google.common.base.Optional; import com.google.common.base.Predicate; import com.google.common.base.Predicates; +import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.google.common.reflect.TypeToken; @@ -107,7 +110,7 @@ import com.google.inject.Guice; /** * Tests behavior of {@link VCloudDirectorApi} and acts as parent for other api live tests. - * + * * @author Adrian Cole * @author grkvlt@apache.org */ @@ -128,13 +131,17 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest< public Predicate retryTaskSuccessLong; protected RestContext adminContext; - protected RestContext context; // FIXME: rename to userContext? + protected RestContext context; // FIXME: rename to + // userContext? protected Session adminSession; protected Session session; + protected String orgUrn; + protected Org org; protected String catalogUrn; private Catalog catalog; - protected URI vAppTemplateURI; + protected String vAppTemplateUrn; + private VAppTemplate vAppTemplate; protected URI mediaURI; protected String networkUrn; private Network network; @@ -154,8 +161,6 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest< protected VCloudDirectorTestSession testSession; - protected Org org; - protected static String testStamp; @BeforeClass(alwaysRun = true) @@ -185,13 +190,8 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest< @Override protected void initializeContext() { Properties overrides = setupProperties(); - testSession = VCloudDirectorTestSession.builder() - .provider(provider) - .identity(identity) - .credential(credential) - .endpoint(endpoint) - .overrides(overrides) - .build(); + testSession = VCloudDirectorTestSession.builder().provider(provider).identity(identity).credential(credential) + .endpoint(endpoint).overrides(overrides).build(); context = testSession.getUserContext(); adminContext = testSession.getAdminContext(); @@ -220,10 +220,12 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest< return getRoleReferenceFor(name, adminContext); } - public static Reference getRoleReferenceFor(String name, RestContext adminContext) { + public static Reference getRoleReferenceFor(String name, + RestContext adminContext) { RoleReferences roles = adminContext.getApi().getQueryApi().roleReferencesQueryAll(); // backend in a builder to strip out unwanted xml cruft that the api chokes on - return Reference.builder().fromReference(find(roles.getReferences(), ReferencePredicates.nameEquals(name))).build(); + return Reference.builder().fromReference(find(roles.getReferences(), ReferencePredicates.nameEquals(name))) + .build(); } public User randomTestUser(String prefix) { @@ -231,29 +233,16 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest< } public User randomTestUser(String prefix, Reference role) { - return User.builder() - .name(name(prefix)+getTestDateTimeStamp()) - .fullName("testFullName") - .emailAddress("test@test.com") - .telephone("555-1234") - .isEnabled(false) - .im("testIM") - .isAlertEnabled(false) - .alertEmailPrefix("testPrefix") - .alertEmail("testAlert@test.com") - .isExternal(false) - .isGroupRole(false) - .role(role) - .password("password") - .build(); + return User.builder().name(name(prefix) + getTestDateTimeStamp()).fullName("testFullName") + .emailAddress("test@test.com").telephone("555-1234").isEnabled(false).im("testIM").isAlertEnabled(false) + .alertEmailPrefix("testPrefix").alertEmail("testAlert@test.com").isExternal(false).isGroupRole(false) + .role(role).password("password").build(); } protected void initTestParametersFromPropertiesOrLazyDiscover() { catalogUrn = emptyToNull(System.getProperty("test." + provider + ".catalog-id")); - String vAppTemplateId = emptyToNull(System.getProperty("test." + provider + ".vapptemplate-id")); - if (vAppTemplateId != null) - vAppTemplateURI = URI.create(endpoint + "/vAppTemplate/" + vAppTemplateId); + vAppTemplateUrn = emptyToNull(System.getProperty("test." + provider + ".vapptemplate-id")); vdcUrn = emptyToNull(System.getProperty("test." + provider + ".vdc-id")); @@ -265,43 +254,132 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest< userUrn = emptyToNull(System.getProperty("test." + provider + ".user-id")); - org = context.getApi().getOrgApi().get( - find(context.getApi().getOrgApi().list(), - ReferencePredicates. nameEquals(session.get())).getHref()); - - if (any(Lists.newArrayList(vAppTemplateURI, networkUrn, vdcUrn), Predicates.isNull())) { + org = context + .getApi() + .getOrgApi() + .get(find(context.getApi().getOrgApi().list(), ReferencePredicates. nameEquals(session.get())) + .getHref()); + orgUrn = org.getId(); + + if (any(Lists.newArrayList(vAppTemplateUrn, networkUrn, vdcUrn), Predicates.isNull())) { if (vdcUrn == null) { - vdc = context.getApi().getVdcApi().get(find(org.getLinks(), - ReferencePredicates. typeEquals(VDC)).getHref()); + vdc = context.getApi().getVdcApi() + .get(find(org.getLinks(), ReferencePredicates. typeEquals(VDC)).getHref()); vdcUrn = vdc.getId(); + + if (vAppTemplateUrn == null) { + Reference vAppTemplateRef = Iterables.find(vdc.getResourceEntities(), + ReferencePredicates. typeEquals(VAPP_TEMPLATE)); + vAppTemplate = context.getApi().getVAppTemplateApi().get(vAppTemplateRef.getHref()); + vAppTemplateUrn = vAppTemplate.getId(); + } + } if (networkUrn == null) { - network = context.getApi().getNetworkApi().get(find(org.getLinks(), - ReferencePredicates. typeEquals(ORG_NETWORK)).getHref()); - networkUrn = network.getId(); + Optional optionalNetwork = tryFindBridgedNetworkInOrg(); + if (optionalNetwork.isPresent()) { + network = optionalNetwork.get(); + networkUrn = network.getId(); + } } if (catalogUrn == null) { - catalog = context.getApi().getCatalogApi().get(find(org.getLinks(), - ReferencePredicates. typeEquals(CATALOG)).getHref()); - catalogUrn = catalog.getId(); + Optional optionalCatalog = tryFindWritableCatalogInOrg(); + if (optionalCatalog.isPresent()) { + catalog = optionalCatalog.get(); + catalogUrn = catalog.getId(); + } } } } - + + Function prettyCatalog = new Function() { + + @Override + public String apply(Catalog input) { + return Objects.toStringHelper("").omitNullValues().add("name", input.getName()).add("id", input.getId()) + .add("owner", input.getOwner()).add("isPublished", input.isPublished()).toString(); + } + + }; + + /** + * If I can add to a catalog, I can write to it + */ + public Optional tryFindWritableCatalogInOrg() { + FluentIterable catalogs = FluentIterable.from(org.getLinks()) + .filter(ReferencePredicates. typeEquals(CATALOG)).transform(new Function() { + @Override + public Catalog apply(Link in) { + return context.getApi().getCatalogApi().get(in.getHref()); + } + }); + + Optional optionalCatalog = tryFind(catalogs, new Predicate() { + + @Override + public boolean apply(Catalog input) { + return Iterables.any(input.getLinks(), LinkPredicates.relEquals(Rel.ADD)); + } + + }); + if (optionalCatalog.isPresent()) { + Logger.CONSOLE.info("found catalog: %s", prettyCatalog.apply(optionalCatalog.get())); + } else { + Logger.CONSOLE.warn("%s doesn't own any catalogs in org %s; catalogs: %s", context.getApi() + .getCurrentSession().getUser(), org.getName(), Iterables.transform(catalogs, prettyCatalog)); + } + return optionalCatalog; + } + + Function prettyNetwork = new Function() { + + @Override + public String apply(Network input) { + return Objects.toStringHelper("").omitNullValues().add("name", input.getName()).add("id", input.getId()) + .add("fenceMode", input.getConfiguration().getFenceMode()) + .add("taskCount", input.getTasks().size() > 0 ? input.getTasks().size() : null).toString(); + } + + }; + + public Optional tryFindBridgedNetworkInOrg() { + FluentIterable networks = FluentIterable.from(org.getLinks()) + .filter(ReferencePredicates. typeEquals(ORG_NETWORK)).transform(new Function() { + @Override + public Network apply(Link in) { + return context.getApi().getNetworkApi().get(in.getHref()); + } + }); + + Optional optionalNetwork = tryFind(networks, new Predicate() { + + @Override + public boolean apply(Network input) { + if (input.getConfiguration().getFenceMode().equals(Network.FenceMode.BRIDGED)) { + if (input.getTasks().size() == 0) { + return true; + } + } + return false; + } + + }); + if (optionalNetwork.isPresent()) { + Logger.CONSOLE.info("found network: %s", prettyNetwork.apply(optionalNetwork.get())); + } else { + Logger.CONSOLE.warn("no ready bridged networks present in org %s; networks: %s", org.getName(), + Iterables.transform(networks, prettyNetwork)); + } + return optionalNetwork; + } + protected Vdc lazyGetVdc() { if (vdc == null) { assertNotNull(vdcUrn, String.format(URN_REQ_LIVE, VDC)); - vdc = from(org.getLinks()).filter(LinkPredicates.typeEquals(VDC)) - .transform(new Function() { - - @Override - public Vdc apply(Link in) { - return context.getApi().getVdcApi().get(in.getHref()); - } - }).firstMatch(EntityPredicates.idEquals(vdcUrn)).get(); + vdc = context.getApi().getVdcApi().get(vdcUrn); assertNotNull(vdc, String.format(ENTITY_NON_NULL, VDC)); } return vdc; @@ -310,30 +388,16 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest< protected Network lazyGetNetwork() { if (network == null) { assertNotNull(networkUrn, String.format(URN_REQ_LIVE, NETWORK)); - network = from(org.getLinks()).filter(LinkPredicates.typeEquals(ORG_NETWORK)) - .transform(new Function() { - - @Override - public Network apply(Link in) { - return context.getApi().getNetworkApi().get(in.getHref()); - } - }).firstMatch(EntityPredicates.idEquals(networkUrn)).get(); + network = context.getApi().getNetworkApi().get(networkUrn); assertNotNull(network, String.format(ENTITY_NON_NULL, NETWORK)); } return network; } - + protected Catalog lazyGetCatalog() { if (catalog == null) { assertNotNull(catalogUrn, String.format(URN_REQ_LIVE, CATALOG)); - catalog = from(org.getLinks()).filter(LinkPredicates.typeEquals(CATALOG)) - .transform(new Function() { - - @Override - public Catalog apply(Link in) { - return context.getApi().getCatalogApi().get(in.getHref()); - } - }).firstMatch(EntityPredicates.idEquals(catalogUrn)).get(); + catalog = context.getApi().getCatalogApi().get(catalogUrn); assertNotNull(catalog, String.format(ENTITY_NON_NULL, CATALOG)); } return catalog; @@ -347,7 +411,16 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest< } return user; } - + + protected VAppTemplate lazyGetVAppTemplate() { + if (vAppTemplate == null) { + assertNotNull(vAppTemplateUrn, String.format(URN_REQ_LIVE, VAPP_TEMPLATE)); + vAppTemplate = adminContext.getApi().getVAppTemplateApi().get(vAppTemplateUrn); + assertNotNull(vAppTemplate, String.format(ENTITY_NON_NULL, VAPP_TEMPLATE)); + } + return vAppTemplate; + } + @Deprecated public URI toAdminUri(Reference ref) { return toAdminUri(ref.getHref()); @@ -369,33 +442,33 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest< protected boolean taskStatusEventually(Task task, Task.Status running, ImmutableSet immutableSet) { TaskApi taskApi = context.getApi().getTaskApi(); TaskStatusEquals predicate = new TaskStatusEquals(taskApi, running, immutableSet); - RetryablePredicate retryablePredicate = new RetryablePredicate(predicate, TASK_TIMEOUT_SECONDS * 1000L); + RetryablePredicate retryablePredicate = new RetryablePredicate(predicate, + TASK_TIMEOUT_SECONDS * 1000L); return retryablePredicate.apply(task); } protected void assertTaskStatusEventually(Task task, Task.Status running, ImmutableSet immutableSet) { assertTrue(taskStatusEventually(task, running, immutableSet), - String.format("Task '%s' must reach status %s", task.getOperationName(), running)); + String.format("Task '%s' must reach status %s", task.getOperationName(), running)); } protected boolean taskDoneEventually(Task task) { TaskApi taskApi = context.getApi().getTaskApi(); - TaskStatusEquals predicate = new TaskStatusEquals( - taskApi, - ImmutableSet.of(Task.Status.ABORTED, Task.Status.CANCELED, Task.Status.ERROR, Task.Status.SUCCESS), - Collections.emptySet()); - RetryablePredicate retryablePredicate = new RetryablePredicate(predicate, LONG_TASK_TIMEOUT_SECONDS * 1000L); + TaskStatusEquals predicate = new TaskStatusEquals(taskApi, ImmutableSet.of(Task.Status.ABORTED, + Task.Status.CANCELED, Task.Status.ERROR, Task.Status.SUCCESS), Collections. emptySet()); + RetryablePredicate retryablePredicate = new RetryablePredicate(predicate, + LONG_TASK_TIMEOUT_SECONDS * 1000L); return retryablePredicate.apply(task); } protected void assertTaskDoneEventually(Task task) { - assertTrue(taskDoneEventually(task), - String.format("Task '%s' must complete", task.getOperationName())); + assertTrue(taskDoneEventually(task), String.format("Task '%s' must complete", task.getOperationName())); } /** - * Instantiate a {@link VApp} in a {@link Vdc} using the {@link VAppTemplate} we have configured for the tests. - * + * Instantiate a {@link VApp} in a {@link Vdc} using the {@link VAppTemplate} we have configured + * for the tests. + * * @return the VApp that is being instantiated */ protected VApp instantiateVApp() { @@ -403,21 +476,17 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest< } protected VApp instantiateVApp(String name) { - InstantiateVAppTemplateParams instantiate = InstantiateVAppTemplateParams.builder() - .name(name) - .notDeploy() - .notPowerOn() - .description("Test VApp") - .instantiationParams(instantiationParams()) - .source(Reference.builder().href(vAppTemplateURI).build()) - .build(); + InstantiateVAppTemplateParams instantiate = InstantiateVAppTemplateParams.builder().name(name).notDeploy() + .notPowerOn().description("Test VApp").instantiationParams(instantiationParams()) + .source(Reference.builder().href(lazyGetVAppTemplate().getHref()).build()).build(); VdcApi vdcApi = context.getApi().getVdcApi(); VApp vAppInstantiated = vdcApi.instantiateVApp(vdcUrn, instantiate); assertNotNull(vAppInstantiated, String.format(ENTITY_NON_NULL, VAPP)); Task instantiationTask = getFirst(vAppInstantiated.getTasks(), null); - if (instantiationTask != null) assertTaskSucceedsLong(instantiationTask); + if (instantiationTask != null) + assertTaskSucceedsLong(instantiationTask); // Save VApp name for cleanUp vAppNames.add(name); @@ -428,23 +497,19 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest< /** Build an {@link InstantiationParams} object. */ protected InstantiationParams instantiationParams() { InstantiationParams instantiationParams = InstantiationParams.builder() - .sections(ImmutableSet.of(networkConfigSection())) - .build(); + .sections(ImmutableSet.of(networkConfigSection())).build(); return instantiationParams; } /** Build a {@link NetworkConfigSection} object. */ private NetworkConfigSection networkConfigSection() { - NetworkConfigSection networkConfigSection = NetworkConfigSection.builder() - .info("Configuration parameters for logical networks") - .networkConfigs( - ImmutableSet.of( - VAppNetworkConfiguration.builder() - .networkName("vAppNetwork") - .configuration(networkConfiguration()) - .build())) - .build(); + NetworkConfigSection networkConfigSection = NetworkConfigSection + .builder() + .info("Configuration parameters for logical networks") + .networkConfigs( + ImmutableSet.of(VAppNetworkConfiguration.builder().networkName("vAppNetwork") + .configuration(networkConfiguration()).build())).build(); return networkConfigSection; } @@ -470,10 +535,8 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest< } // Build the configuration object - NetworkConfiguration networkConfiguration = NetworkConfiguration.builder() - .parentNetwork(parentNetwork.get()) - .fenceMode(Network.FenceMode.BRIDGED) - .build(); + NetworkConfiguration networkConfiguration = NetworkConfiguration.builder().parentNetwork(parentNetwork.get()) + .fenceMode(Network.FenceMode.BRIDGED).build(); return networkConfiguration; } @@ -481,27 +544,23 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest< protected void cleanUpVAppTemplate(VAppTemplate vAppTemplate) { VAppTemplateApi vappTemplateApi = context.getApi().getVAppTemplateApi(); try { - Task task = vappTemplateApi.removeVappTemplate(vAppTemplate.getHref()); - taskDoneEventually(task); + Task task = vappTemplateApi.remove(vAppTemplate.getId()); + taskDoneEventually(task); } catch (Exception e) { logger.warn(e, "Error deleting template '%s'", vAppTemplate.getName()); } - } - - protected void cleanUpVApp(VApp vApp) { - cleanUpVApp(vApp.getHref()); } - // TODO code tidy for cleanUpVApp? Seems extremely verbose! - protected void cleanUpVApp(URI vAppURI) { + protected void cleanUpVApp(VApp vApp) { VAppApi vAppApi = context.getApi().getVAppApi(); - VApp vApp = vAppApi.getVApp(vAppURI); // Refresh + String vAppUrn = vApp.getId(); + vApp = vAppApi.get(vAppUrn); // Refresh if (vApp == null) { - logger.info("Cannot find VApp at %s", vAppURI.getPath()); + logger.info("Cannot find VApp at %s", vAppUrn); return; // Presumably vApp has already been removed. Ignore. } - logger.debug("Deleting VApp %s (%s)", vApp.getName(), vAppURI.getPath()); + logger.debug("Deleting VApp %s (%s)", vApp.getName(), vAppUrn); // Wait for busy tasks to complete (don't care if it's failed or successful) // Otherwise, get error on remove "entity is busy completing an operation. @@ -516,7 +575,7 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest< // Shutdown and power off the VApp if necessary if (vApp.getStatus() == Status.POWERED_ON) { try { - Task shutdownTask = vAppApi.shutdown(vAppURI); + Task shutdownTask = vAppApi.shutdown(vAppUrn); taskDoneEventually(shutdownTask); } catch (Exception e) { // keep going; cleanup as much as possible @@ -528,9 +587,8 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest< if (vApp.isDeployed()) { try { UndeployVAppParams params = UndeployVAppParams.builder() - .undeployPowerAction(UndeployVAppParams.PowerAction.SHUTDOWN) - .build(); - Task undeployTask = vAppApi.undeploy(vAppURI, params); + .undeployPowerAction(UndeployVAppParams.PowerAction.SHUTDOWN).build(); + Task undeployTask = vAppApi.undeploy(vAppUrn, params); taskDoneEventually(undeployTask); } catch (Exception e) { // keep going; cleanup as much as possible @@ -539,13 +597,13 @@ public abstract class BaseVCloudDirectorApiLiveTest extends BaseContextLiveTest< } try { - Task task = vAppApi.removeVApp(vAppURI); + Task task = vAppApi.remove(vAppUrn); taskDoneEventually(task); vAppNames.remove(vApp.getName()); logger.info("Deleted VApp %s", vApp.getName()); } catch (Exception e) { - vApp = vAppApi.getVApp(vAppURI); // Refresh - logger.warn(e, "Deleting VApp %s failed (%s)", vApp.getName(), vAppURI.getPath()); + vApp = vAppApi.get(vApp.getId()); // Refresh + logger.warn(e, "Deleting VApp %s failed (%s)", vApp.getName(), vAppUrn); } }