Search in sources :

Example 1 with EventQuery

use of io.gravitee.rest.api.model.EventQuery in project gravitee-management-rest-api by gravitee-io.

the class ApiEventsResource method getApiEventsEvents.

@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Get API's events", notes = "User must have the MANAGE_LIFECYCLE permission to use this service")
@ApiResponses({ @ApiResponse(code = 200, message = "API's events"), @ApiResponse(code = 500, message = "Internal server error") })
@Permissions({ @Permission(value = RolePermission.API_EVENT, acls = RolePermissionAction.READ) })
public List<EventEntity> getApiEventsEvents(@ApiParam @DefaultValue("all") @QueryParam("type") EventTypeListParam eventTypeListParam) {
    final EventQuery query = new EventQuery();
    query.setApi(api);
    return eventService.search(query).stream().filter(event -> eventTypeListParam.getEventTypes().contains(event.getType())).sorted((e1, e2) -> e2.getCreatedAt().compareTo(e1.getCreatedAt())).collect(Collectors.toList());
}
Also used : RolePermissionAction(io.gravitee.rest.api.model.permissions.RolePermissionAction) ApiEntity(io.gravitee.rest.api.model.api.ApiEntity) Arrays(java.util.Arrays) Event(io.gravitee.repository.management.model.Event) Page(io.gravitee.common.data.domain.Page) ApiNotFoundException(io.gravitee.rest.api.service.exceptions.ApiNotFoundException) HashMap(java.util.HashMap) Collectors(java.util.stream.Collectors) Permission(io.gravitee.rest.api.management.rest.security.Permission) EventService(io.gravitee.rest.api.service.EventService) Inject(javax.inject.Inject) EventEntity(io.gravitee.rest.api.model.EventEntity) List(java.util.List) MediaType(io.gravitee.common.http.MediaType) javax.ws.rs(javax.ws.rs) EventQuery(io.gravitee.rest.api.model.EventQuery) Map(java.util.Map) io.swagger.annotations(io.swagger.annotations) EventTypeListParam(io.gravitee.rest.api.management.rest.resource.param.EventTypeListParam) Permissions(io.gravitee.rest.api.management.rest.security.Permissions) EventSearchParam(io.gravitee.rest.api.management.rest.resource.param.EventSearchParam) RolePermission(io.gravitee.rest.api.model.permissions.RolePermission) EventQuery(io.gravitee.rest.api.model.EventQuery) Permissions(io.gravitee.rest.api.management.rest.security.Permissions)

Aggregations

Page (io.gravitee.common.data.domain.Page)1 MediaType (io.gravitee.common.http.MediaType)1 Event (io.gravitee.repository.management.model.Event)1 EventSearchParam (io.gravitee.rest.api.management.rest.resource.param.EventSearchParam)1 EventTypeListParam (io.gravitee.rest.api.management.rest.resource.param.EventTypeListParam)1 Permission (io.gravitee.rest.api.management.rest.security.Permission)1 Permissions (io.gravitee.rest.api.management.rest.security.Permissions)1 EventEntity (io.gravitee.rest.api.model.EventEntity)1 EventQuery (io.gravitee.rest.api.model.EventQuery)1 ApiEntity (io.gravitee.rest.api.model.api.ApiEntity)1 RolePermission (io.gravitee.rest.api.model.permissions.RolePermission)1 RolePermissionAction (io.gravitee.rest.api.model.permissions.RolePermissionAction)1 EventService (io.gravitee.rest.api.service.EventService)1 ApiNotFoundException (io.gravitee.rest.api.service.exceptions.ApiNotFoundException)1 io.swagger.annotations (io.swagger.annotations)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1