Search in sources :

Example 11 with Builder

use of com.vmware.xenon.services.common.QueryTask.Query.Builder in project photon-model by vmware.

the class VSphereAdapterImageEnumerationService method collectAllEndpointImages.

private DeferredResult<Set<String>> collectAllEndpointImages(ImageEnumerateRequest req) {
    Builder builder = Query.Builder.create().addKindFieldClause(ImageState.class).addFieldClause(ImageState.FIELD_NAME_ENDPOINT_LINK, req.resourceLink());
    QueryTask task = QueryTask.Builder.createDirectTask().setQuery(builder.build()).setResultLimit(QueryUtils.DEFAULT_RESULT_LIMIT).build();
    DeferredResult<Set<String>> res = new DeferredResult<>();
    Set<String> imageLinks = new ConcurrentSkipListSet<>();
    QueryUtils.startInventoryQueryTask(this, task).whenComplete((result, e) -> {
        if (e != null) {
            res.complete(new HashSet<>());
            return;
        }
        if (result.results.nextPageLink == null) {
            res.complete(imageLinks);
            return;
        }
        Operation.createGet(PhotonModelUriUtils.createInventoryUri(getHost(), result.results.nextPageLink)).setCompletion(makeCompletion(imageLinks, res)).sendWith(this);
    });
    return res;
}
Also used : QueryTask(com.vmware.xenon.services.common.QueryTask) HashSet(java.util.HashSet) Set(java.util.Set) ConcurrentSkipListSet(java.util.concurrent.ConcurrentSkipListSet) ConcurrentSkipListSet(java.util.concurrent.ConcurrentSkipListSet) Builder(com.vmware.xenon.services.common.QueryTask.Query.Builder) ImageState(com.vmware.photon.controller.model.resources.ImageService.ImageState) DeferredResult(com.vmware.xenon.common.DeferredResult)

Example 12 with Builder

use of com.vmware.xenon.services.common.QueryTask.Query.Builder in project photon-model by vmware.

the class VSphereHostSystemEnumerationHelper method queryForHostSystem.

/**
 * Builds a query for finding a HostSystems by its manage object reference.
 */
private static QueryTask queryForHostSystem(EnumerationProgress ctx, String parentComputeLink, String moRefId) {
    Builder builder = Builder.create().addKindFieldClause(ComputeState.class).addFieldClause(ComputeState.FIELD_NAME_ID, moRefId).addFieldClause(ComputeState.FIELD_NAME_PARENT_LINK, parentComputeLink);
    QueryUtils.addEndpointLink(builder, ComputeState.class, ctx.getRequest().endpointLink);
    QueryUtils.addTenantLinks(builder, ctx.getTenantLinks());
    return QueryTask.Builder.createDirectTask().setQuery(builder.build()).addOption(QueryOption.EXPAND_CONTENT).build();
}
Also used : Builder(com.vmware.xenon.services.common.QueryTask.Query.Builder)

Example 13 with Builder

use of com.vmware.xenon.services.common.QueryTask.Query.Builder in project photon-model by vmware.

the class VsphereFolderEnumerationHelper method queryForFolder.

private static QueryTask queryForFolder(EnumerationProgress ctx, FolderOverlay folder) {
    String moref = VimUtils.convertMoRefToString(folder.getId());
    Builder builder = QueryTask.Query.Builder.create().addKindFieldClause(ResourceGroupState.class).addCompositeFieldClause(ResourceState.FIELD_NAME_CUSTOM_PROPERTIES, CustomProperties.MOREF, moref);
    QueryUtils.addEndpointLink(builder, ResourceGroupService.ResourceGroupState.class, ctx.getRequest().endpointLink);
    QueryUtils.addTenantLinks(builder, ctx.getTenantLinks());
    return QueryTask.Builder.createDirectTask().setQuery(builder.build()).build();
}
Also used : ResourceGroupService(com.vmware.photon.controller.model.resources.ResourceGroupService) ResourceGroupState(com.vmware.photon.controller.model.resources.ResourceGroupService.ResourceGroupState) Builder(com.vmware.xenon.services.common.QueryTask.Query.Builder)

Example 14 with Builder

use of com.vmware.xenon.services.common.QueryTask.Query.Builder in project photon-model by vmware.

the class VsphereStoragePolicyEnumerationHelper method queryForStoragePolicy.

static QueryTask queryForStoragePolicy(EnumerationProgress ctx, String id, String name) {
    Builder builder = Builder.create().addFieldClause(ResourceState.FIELD_NAME_ID, id).addKindFieldClause(ResourceGroupState.class).addCaseInsensitiveFieldClause(ResourceState.FIELD_NAME_NAME, name, MatchType.TERM, Occurance.MUST_OCCUR);
    QueryUtils.addTenantLinks(builder, ctx.getTenantLinks());
    return QueryTask.Builder.createDirectTask().setQuery(builder.build()).build();
}
Also used : ResourceGroupState(com.vmware.photon.controller.model.resources.ResourceGroupService.ResourceGroupState) Builder(com.vmware.xenon.services.common.QueryTask.Query.Builder)

Aggregations

Builder (com.vmware.xenon.services.common.QueryTask.Query.Builder)14 QueryByPages (com.vmware.photon.controller.model.query.QueryUtils.QueryByPages)3 ResourceGroupState (com.vmware.photon.controller.model.resources.ResourceGroupService.ResourceGroupState)3 SubnetState (com.vmware.photon.controller.model.resources.SubnetService.SubnetState)3 NetworkState (com.vmware.photon.controller.model.resources.NetworkService.NetworkState)2 QueryTask (com.vmware.xenon.services.common.QueryTask)2 URI (java.net.URI)2 ApplicationTokenCredentials (com.microsoft.azure.credentials.ApplicationTokenCredentials)1 ComputeProperties (com.vmware.photon.controller.model.ComputeProperties)1 ComputeEnumerateResourceRequest (com.vmware.photon.controller.model.adapterapi.ComputeEnumerateResourceRequest)1 EnumerationAction (com.vmware.photon.controller.model.adapterapi.EnumerationAction)1 AzureUriPaths (com.vmware.photon.controller.model.adapters.azure.AzureUriPaths)1 AzureConstants (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants)1 AUTH_HEADER_BEARER_PREFIX (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AUTH_HEADER_BEARER_PREFIX)1 AzureResourceType (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AzureResourceType)1 DEFAULT_INSTANCE_ADAPTER_REFERENCE (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.DEFAULT_INSTANCE_ADAPTER_REFERENCE)1 LIST_VIRTUAL_NETWORKS_URI (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.LIST_VIRTUAL_NETWORKS_URI)1 NETWORK_REST_API_VERSION (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.NETWORK_REST_API_VERSION)1 QUERY_PARAM_API_VERSION (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.QUERY_PARAM_API_VERSION)1 ResourceGroupStateType (com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.ResourceGroupStateType)1