use of com.emc.storageos.model.host.HostList in project coprhd-controller by CoprHD.
the class HostService method listHosts.
/**
* Lists the id and name for all the hosts that belong to the given tenant organization.
*
* @param tid
* the URN of a ViPR tenant organization
* @prereq none
* @brief List hosts
* @return a list of hosts that belong to the tenant organization.
* @throws DatabaseException
* when a DB error occurs
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public HostList listHosts(@QueryParam("tenant") final URI tid) throws DatabaseException {
URI tenantId;
StorageOSUser user = getUserFromContext();
if (tid == null || StringUtils.isBlank(tid.toString())) {
tenantId = URI.create(user.getTenantId());
} else {
tenantId = tid;
}
// this call validates the tenant id
TenantOrg tenant = _permissionsHelper.getObjectById(tenantId, TenantOrg.class);
ArgValidator.checkEntity(tenant, tenantId, isIdEmbeddedInURL(tenantId), true);
// check the user permissions for this tenant org
verifyAuthorizedInTenantOrg(tenantId, user);
// get all host children
HostList list = new HostList();
list.setHosts(map(ResourceTypeEnum.HOST, listChildren(tenantId, Host.class, "label", "tenant")));
return list;
}
Aggregations