Search in sources :

Example 21 with SearchQuery

use of org.graylog2.search.SearchQuery in project graylog2-server by Graylog2.

the class EventNotificationsResource method listNotifications.

@GET
@ApiOperation("List all available notifications")
public PaginatedResponse<NotificationDto> listNotifications(@ApiParam(name = "page") @QueryParam("page") @DefaultValue("1") int page, @ApiParam(name = "per_page") @QueryParam("per_page") @DefaultValue("50") int perPage, @ApiParam(name = "query") @QueryParam("query") @DefaultValue("") String query) {
    final SearchQuery searchQuery = searchQueryParser.parse(query);
    final PaginatedList<NotificationDto> result = dbNotificationService.searchPaginated(searchQuery, notification -> {
        return isPermitted(RestPermissions.EVENT_NOTIFICATIONS_READ, notification.id());
    }, "title", page, perPage);
    return PaginatedResponse.create("notifications", result, query);
}
Also used : SearchQuery(org.graylog2.search.SearchQuery) NotificationDto(org.graylog.events.notifications.NotificationDto) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)21 SearchQuery (org.graylog2.search.SearchQuery)21 GET (javax.ws.rs.GET)20 BadRequestException (javax.ws.rs.BadRequestException)17 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)15 Path (javax.ws.rs.Path)13 Produces (javax.ws.rs.Produces)10 Timed (com.codahale.metrics.annotation.Timed)9 Api (io.swagger.annotations.Api)7 ApiParam (io.swagger.annotations.ApiParam)7 List (java.util.List)7 Collectors (java.util.stream.Collectors)7 Inject (javax.inject.Inject)7 PUT (javax.ws.rs.PUT)7 MediaType (javax.ws.rs.core.MediaType)7 RequiresAuthentication (org.apache.shiro.authz.annotation.RequiresAuthentication)7 ImmutableMap (com.google.common.collect.ImmutableMap)6 Map (java.util.Map)6 DELETE (javax.ws.rs.DELETE)6 DefaultValue (javax.ws.rs.DefaultValue)6