Issue 830: Add missing operations to Org clients

This commit is contained in:
Andrew Donald Kennedy 2012-03-21 16:39:50 +00:00
parent 78a4a674ab
commit 235ed12337
3 changed files with 70 additions and 2 deletions

View File

@ -18,18 +18,25 @@
*/ */
package org.jclouds.vcloud.director.v1_5.features; package org.jclouds.vcloud.director.v1_5.features;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.CONTROL_ACCESS;
import java.net.URI; import java.net.URI;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path; 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.Delegate;
import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.JAXBResponseParser;
import org.jclouds.rest.annotations.RequestFilters; 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.Org;
import org.jclouds.vcloud.director.v1_5.domain.OrgList; import org.jclouds.vcloud.director.v1_5.domain.OrgList;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
@ -61,6 +68,28 @@ public interface OrgAsyncClient {
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<? extends Org> getOrg(@EndpointParam URI orgUri); ListenableFuture<? extends Org> 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<ControlAccessParams> 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<ControlAccessParams> getControlAccess(@EndpointParam URI orgURI, @PathParam("catalogId") String catalogId);
/** /**
* @return asynchronous access to {@link Metadata.Readable} features * @return asynchronous access to {@link Metadata.Readable} features

View File

@ -23,7 +23,7 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate; 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.Org;
import org.jclouds.vcloud.director.v1_5.domain.OrgList; import org.jclouds.vcloud.director.v1_5.domain.OrgList;
@ -58,6 +58,28 @@ public interface OrgClient {
* @return the org or null if not found * @return the org or null if not found
*/ */
Org getOrg(URI orgRef); Org getOrg(URI orgRef);
/**
* Modifies a catalog control access.
*
* <pre>
* POST /org/{id}/catalog/{catalogId}/action/controlAccess
* </pre>
*
* @return the control access information
*/
ControlAccessParams modifyControlAccess(URI orgRef, String catalogId, ControlAccessParams params);
/**
* Retrieves the catalog control access information.
*
* <pre>
* GET /org/{id}/catalog/{catalogId}/controlAccess
* </pre>
*
* @return the control access information
*/
ControlAccessParams getControlAccess(URI orgRef, String catalogId);
/** /**
* @return synchronous access to {@link Metadata.Readable} features * @return synchronous access to {@link Metadata.Readable} features

View File

@ -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.checkMetadataValue;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkOrg; 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.checkReferenceType;
import static org.jclouds.vcloud.director.v1_5.domain.Checks.*;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
@ -32,6 +33,7 @@ import static org.testng.Assert.assertNotNull;
import java.net.URI; import java.net.URI;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; 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.Metadata;
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue; import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
import org.jclouds.vcloud.director.v1_5.domain.Org; import org.jclouds.vcloud.director.v1_5.domain.Org;
@ -142,4 +144,19 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
checkMetadataValue(value); checkMetadataValue(value);
assertEquals(value.getValue(), expected, String.format(CORRECT_VALUE_OBJECT_FMT, "Value", "MetadataValue", expected, value.getValue())); 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);
}
} }