use of org.graylog2.alerts.Alert.AlertState in project graylog2-server by Graylog2.
the class AlertResource method listPaginated.
@GET
@Timed
@Path("paginated")
@ApiOperation(value = "Get alarms of all streams, filtered by specifying limit and offset parameters.")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid ObjectId.") })
public AlertListSummary listPaginated(@ApiParam(name = "skip", value = "The number of elements to skip (offset).", required = true) @QueryParam("skip") @DefaultValue("0") int skip, @ApiParam(name = "limit", value = "The maximum number of elements to return.", required = true) @QueryParam("limit") @DefaultValue("300") int limit, @ApiParam(name = "state", value = "Alert state (resolved/unresolved)", required = false) @QueryParam("state") String state) throws NotFoundException {
final List<String> allowedStreamIds = getAllowedStreamIds();
AlertState alertState;
try {
alertState = AlertState.fromString(state);
} catch (IllegalArgumentException e) {
alertState = AlertState.ANY;
}
final Stream<Alert> alertsStream = alertService.listForStreamIds(allowedStreamIds, alertState, skip, limit).stream();
final List<AlertSummary> alerts = getAlertSummaries(alertsStream);
return AlertListSummary.create(alertService.totalCountForStreams(allowedStreamIds, alertState), alerts);
}
Aggregations