Search in sources :

Example 1 with AlertState

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);
}
Also used : Alert(org.graylog2.alerts.Alert) AlertSummary(org.graylog2.rest.models.streams.alerts.AlertSummary) AlertState(org.graylog2.alerts.Alert.AlertState) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

Timed (com.codahale.metrics.annotation.Timed)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Alert (org.graylog2.alerts.Alert)1 AlertState (org.graylog2.alerts.Alert.AlertState)1 AlertSummary (org.graylog2.rest.models.streams.alerts.AlertSummary)1