mirror of https://github.com/apache/jclouds.git
Issue 830: Added entity operation to query client
This commit is contained in:
parent
c71ff11fc5
commit
1ccd5f806a
|
@ -21,6 +21,7 @@ package org.jclouds.vcloud.director.v1_5.features;
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
import javax.ws.rs.QueryParam;
|
import javax.ws.rs.QueryParam;
|
||||||
|
|
||||||
import org.jclouds.rest.annotations.ExceptionParser;
|
import org.jclouds.rest.annotations.ExceptionParser;
|
||||||
|
@ -28,6 +29,7 @@ import org.jclouds.rest.annotations.JAXBResponseParser;
|
||||||
import org.jclouds.rest.annotations.QueryParams;
|
import org.jclouds.rest.annotations.QueryParams;
|
||||||
import org.jclouds.rest.annotations.RequestFilters;
|
import org.jclouds.rest.annotations.RequestFilters;
|
||||||
import org.jclouds.rest.annotations.SkipEncoding;
|
import org.jclouds.rest.annotations.SkipEncoding;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Entity;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.query.CatalogReferences;
|
import org.jclouds.vcloud.director.v1_5.domain.query.CatalogReferences;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryList;
|
import org.jclouds.vcloud.director.v1_5.domain.query.QueryList;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords;
|
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords;
|
||||||
|
@ -45,6 +47,16 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
@SkipEncoding({ '=' })
|
@SkipEncoding({ '=' })
|
||||||
public interface QueryAsyncClient {
|
public interface QueryAsyncClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see QueryClient#entity(String)
|
||||||
|
*/
|
||||||
|
@GET
|
||||||
|
@Path("/entity/{id}")
|
||||||
|
@Consumes
|
||||||
|
@JAXBResponseParser
|
||||||
|
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||||
|
ListenableFuture<Entity> entity(@PathParam("id") String id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* REST API General queries handler.
|
* REST API General queries handler.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -21,14 +21,9 @@ package org.jclouds.vcloud.director.v1_5.features;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Catalog;
|
import org.jclouds.vcloud.director.v1_5.domain.Entity;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.CatalogReference;
|
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Link;
|
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.VApp;
|
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
|
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.query.CatalogReferences;
|
import org.jclouds.vcloud.director.v1_5.domain.query.CatalogReferences;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryList;
|
import org.jclouds.vcloud.director.v1_5.domain.query.QueryList;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecordType;
|
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords;
|
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.query.VAppReferences;
|
import org.jclouds.vcloud.director.v1_5.domain.query.VAppReferences;
|
||||||
|
|
||||||
|
@ -41,6 +36,15 @@ import org.jclouds.vcloud.director.v1_5.domain.query.VAppReferences;
|
||||||
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
|
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
|
||||||
public interface QueryClient {
|
public interface QueryClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redirects to the URL of an entity with the given VCD ID.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* GET /entity/{id}
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
|
Entity entity(String id);
|
||||||
|
|
||||||
// TODO Add a typed object for filter syntax, or at least a fluent builder
|
// TODO Add a typed object for filter syntax, or at least a fluent builder
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,7 +18,9 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.features;
|
package org.jclouds.vcloud.director.v1_5.features;
|
||||||
|
|
||||||
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.ENTITY_EQUAL;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.NOT_EMPTY_OBJECT_FMT;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.NOT_EMPTY_OBJECT_FMT;
|
||||||
|
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkEntityType;
|
||||||
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.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
@ -32,6 +34,8 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Entity;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Link;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.ResourceType;
|
import org.jclouds.vcloud.director.v1_5.domain.ResourceType;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.VApp;
|
import org.jclouds.vcloud.director.v1_5.domain.VApp;
|
||||||
|
@ -45,6 +49,7 @@ import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultVAppRecord;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultVAppTemplateRecord;
|
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultVAppTemplateRecord;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultVMRecord;
|
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultVMRecord;
|
||||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.predicates.ReferencePredicates;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -84,6 +89,24 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
vAppClient = context.getApi().getVAppClient();
|
vAppClient = context.getApi().getVAppClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(testName = "GET /entity/{id}")
|
||||||
|
public void testEntity() {
|
||||||
|
// Get a VAppTemplate to look up as an entity
|
||||||
|
VAppTemplate vAppTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI);
|
||||||
|
|
||||||
|
// Method under test
|
||||||
|
Entity entity = queryClient.entity(vAppTemplate.getId());
|
||||||
|
|
||||||
|
// Check returned entity
|
||||||
|
checkEntityType(entity);
|
||||||
|
|
||||||
|
// Retrieve and check template using entity link
|
||||||
|
Link link = Iterables.find(entity.getLinks(), ReferencePredicates.<Link>typeEquals(VCloudDirectorMediaType.VAPP_TEMPLATE));
|
||||||
|
VAppTemplate retrieved = vAppTemplateClient.getVAppTemplate(link.getHref());
|
||||||
|
assertEquals(retrieved, vAppTemplate, String.format(ENTITY_EQUAL, "VAppTemplate"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Test(testName = "GET /query")
|
@Test(testName = "GET /query")
|
||||||
public void testQuery() {
|
public void testQuery() {
|
||||||
VAppTemplate vAppTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI);
|
VAppTemplate vAppTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI);
|
||||||
|
|
Loading…
Reference in New Issue