From 235ed123377c6d08673462d354f1b122c655522c Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Wed, 21 Mar 2012 16:39:50 +0000 Subject: [PATCH] Issue 830: Add missing operations to Org clients --- .../v1_5/features/OrgAsyncClient.java | 31 ++++++++++++++++++- .../director/v1_5/features/OrgClient.java | 24 +++++++++++++- .../v1_5/features/OrgClientLiveTest.java | 17 ++++++++++ 3 files changed, 70 insertions(+), 2 deletions(-) diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncClient.java index 98dc3bb731..5d024165f6 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgAsyncClient.java @@ -18,18 +18,25 @@ */ package org.jclouds.vcloud.director.v1_5.features; +import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.CONTROL_ACCESS; + import java.net.URI; import javax.ws.rs.Consumes; import javax.ws.rs.GET; +import javax.ws.rs.POST; import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.vcloud.director.v1_5.domain.Metadata; +import org.jclouds.rest.binders.BindToXMLPayload; +import org.jclouds.vcloud.director.v1_5.domain.ControlAccessParams; import org.jclouds.vcloud.director.v1_5.domain.Org; import org.jclouds.vcloud.director.v1_5.domain.OrgList; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; @@ -61,6 +68,28 @@ public interface OrgAsyncClient { @JAXBResponseParser @ExceptionParser(ThrowVCloudErrorOn4xx.class) ListenableFuture getOrg(@EndpointParam URI orgUri); + + /** + * @see OrgClient#modifyControlAccess(URI, URI, ControlAccessParams) + */ + @POST + @Path("/catalog/{catalogId}/action/controlAccess") + @Produces(CONTROL_ACCESS) + @Consumes(CONTROL_ACCESS) + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture modifyControlAccess(@EndpointParam URI orgURI, @PathParam("catalogId") String catalogId, + @BinderParam(BindToXMLPayload.class) ControlAccessParams params); + + /** + * @see OrgClient#getControlAccess(URI, URI, ControlAccessParams) + */ + @POST + @Path("/catalog/{catalogId}/controlAccess") + @Consumes + @JAXBResponseParser + @ExceptionParser(ThrowVCloudErrorOn4xx.class) + ListenableFuture getControlAccess(@EndpointParam URI orgURI, @PathParam("catalogId") String catalogId); /** * @return asynchronous access to {@link Metadata.Readable} features diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgClient.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgClient.java index 14ff6a632f..4e937948f9 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgClient.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/features/OrgClient.java @@ -23,7 +23,7 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; -import org.jclouds.vcloud.director.v1_5.domain.Metadata; +import org.jclouds.vcloud.director.v1_5.domain.ControlAccessParams; import org.jclouds.vcloud.director.v1_5.domain.Org; import org.jclouds.vcloud.director.v1_5.domain.OrgList; @@ -58,6 +58,28 @@ public interface OrgClient { * @return the org or null if not found */ Org getOrg(URI orgRef); + + /** + * Modifies a catalog control access. + * + *
+    * POST /org/{id}/catalog/{catalogId}/action/controlAccess
+    * 
+ * + * @return the control access information + */ + ControlAccessParams modifyControlAccess(URI orgRef, String catalogId, ControlAccessParams params); + + /** + * Retrieves the catalog control access information. + * + *
+    * GET /org/{id}/catalog/{catalogId}/controlAccess
+    * 
+ * + * @return the control access information + */ + ControlAccessParams getControlAccess(URI orgRef, String catalogId); /** * @return synchronous access to {@link Metadata.Readable} features diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java index 6ab6bd4497..2ea94a3749 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/features/OrgClientLiveTest.java @@ -25,6 +25,7 @@ import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadata; import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadataValue; import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkOrg; import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkReferenceType; +import static org.jclouds.vcloud.director.v1_5.domain.Checks.*; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; @@ -32,6 +33,7 @@ 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.ControlAccessParams; import org.jclouds.vcloud.director.v1_5.domain.Metadata; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.Org; @@ -142,4 +144,19 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest { checkMetadataValue(value); assertEquals(value.getValue(), expected, String.format(CORRECT_VALUE_OBJECT_FMT, "Value", "MetadataValue", expected, value.getValue())); } + + @Test(testName = "GET /org/{id}/catalog/{catalogId}/controlAccess") + public void testGetontrolAccess() { + String catalogId = ""; + ControlAccessParams params = orgClient.getControlAccess(orgURI, catalogId); + checkControlAccessParams(params); + } + + @Test(testName = "GET /org/{id}/catalog/{catalogId}/action/controlAccess", dependsOnMethods = { "testGetontrolAccess" }) + public void testModifyControlAccess() { + String catalogId = ""; + ControlAccessParams params = orgClient.getControlAccess(orgURI, catalogId); + ControlAccessParams modified = orgClient.modifyControlAccess(orgURI, catalogId, params); + checkControlAccessParams(modified); + } }