use of org.graylog.events.notifications.NotificationDto 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);
}
use of org.graylog.events.notifications.NotificationDto in project graylog2-server by Graylog2.
the class EventNotificationsResource method test.
@POST
@Timed
@Path("/{notificationId}/test")
@ApiOperation(value = "Send a test alert for a given event notification")
@ApiResponses(value = { @ApiResponse(code = 404, message = "Event notification not found."), @ApiResponse(code = 500, message = "Error while testing event notification") })
@NoAuditEvent("only used to test event notifications")
public Response test(@ApiParam(name = "notificationId", value = "The event notification id to send a test alert for.", required = true) @PathParam("notificationId") @NotBlank String notificationId) {
checkPermission(RestPermissions.EVENT_NOTIFICATIONS_EDIT, notificationId);
final NotificationDto notificationDto = dbNotificationService.get(notificationId).orElseThrow(() -> new NotFoundException("Notification " + notificationId + " doesn't exist"));
resourceHandler.test(notificationDto, getSubject().getPrincipal().toString());
return Response.ok().build();
}
Aggregations