Search in sources :

Example 1 with EventList

use of com.emc.storageos.model.event.EventList in project coprhd-controller by CoprHD.

the class Events method listByTenant.

@Override
public List<NamedRelatedResourceRep> listByTenant(URI tenantId) {
    UriBuilder uriBuilder = client.uriBuilder(baseUrl);
    if (tenantId != null) {
        uriBuilder.queryParam(TENANT_PARAM, tenantId);
    }
    EventList response = client.getURI(EventList.class, uriBuilder.build());
    return defaultList(response.getEvents());
}
Also used : EventList(com.emc.storageos.model.event.EventList) UriBuilder(javax.ws.rs.core.UriBuilder)

Example 2 with EventList

use of com.emc.storageos.model.event.EventList in project coprhd-controller by CoprHD.

the class EventService method listEvents.

/**
 * List Events
 *
 * @param tid
 * @brief List events for the queried tenant.
 * @return
 * @throws DatabaseException
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public EventList listEvents(@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
    EventList list = new EventList();
    list.setEvents(DbObjectMapper.map(ResourceTypeEnum.EVENT, listChildren(tenantId, ActionableEvent.class, "label", "tenant")));
    return list;
}
Also used : EventList(com.emc.storageos.model.event.EventList) StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) URI(java.net.URI) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

EventList (com.emc.storageos.model.event.EventList)2 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)1 StorageOSUser (com.emc.storageos.security.authentication.StorageOSUser)1 URI (java.net.URI)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 UriBuilder (javax.ws.rs.core.UriBuilder)1