Search in sources :

Example 1 with ComputeImageList

use of com.emc.storageos.model.compute.ComputeImageList in project coprhd-controller by CoprHD.

the class ComputeImageService method getComputeImages.

/**
 * Returns a list of all compute images.
 *
 * @brief Show compute images
 * @return List of all compute images.
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public ComputeImageList getComputeImages(@QueryParam("imageType") String imageType) {
    log.info("getComputeImages, imageType: {}", imageType);
    // validate query param
    if (imageType != null) {
        ArgValidator.checkFieldValueFromEnum(imageType, "imageType", ComputeImage.ImageType.class);
    }
    List<URI> ids = _dbClient.queryByType(ComputeImage.class, true);
    ComputeImageList list = new ComputeImageList();
    Iterator<ComputeImage> iter = _dbClient.queryIterativeObjects(ComputeImage.class, ids);
    while (iter.hasNext()) {
        ComputeImage img = iter.next();
        if (imageType == null || imageType.equals(img.getImageType())) {
            list.getComputeImages().add(DbObjectMapper.toNamedRelatedResource(img));
        }
    }
    return list;
}
Also used : ComputeImageList(com.emc.storageos.model.compute.ComputeImageList) URI(java.net.URI) ComputeImage(com.emc.storageos.db.client.model.ComputeImage) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with ComputeImageList

use of com.emc.storageos.model.compute.ComputeImageList in project coprhd-controller by CoprHD.

the class ComputeImages method listByImageType.

/**
 * Filter to show only ESX/i compute images.
 *
 * @param imageType
 *            the type of the image (e.g. esx, linux)
 * @return List of ESX/i compute images.
 */
public List<NamedRelatedResourceRep> listByImageType(String imageType) {
    URI getUri = client.uriBuilder(baseUrl).queryParam("imageType", imageType).build();
    ComputeImageList response = client.getURI(ComputeImageList.class, getUri);
    return ResourceUtils.defaultList(response.getComputeImages());
}
Also used : ComputeImageList(com.emc.storageos.model.compute.ComputeImageList) URI(java.net.URI)

Aggregations

ComputeImageList (com.emc.storageos.model.compute.ComputeImageList)2 URI (java.net.URI)2 ComputeImage (com.emc.storageos.db.client.model.ComputeImage)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1