Search in sources :

Example 1 with AlertConditionTestResponse

use of org.graylog2.rest.resources.streams.responses.AlertConditionTestResponse in project graylog2-server by Graylog2.

the class StreamAlertConditionResource method testExisting.

@POST
@Path("{conditionId}/test")
@Timed
@ApiOperation("Test existing alert condition")
@NoAuditEvent("resource doesn't modify any data")
public Response testExisting(@ApiParam(name = "streamId", value = "The stream ID this alert condition belongs to.", required = true) @PathParam("streamId") String streamId, @ApiParam(name = "conditionId", value = "The alert condition ID to be fetched", required = true) @PathParam("conditionId") String conditionId) throws NotFoundException {
    checkPermission(RestPermissions.STREAMS_EDIT, streamId);
    final Stream stream = streamService.load(streamId);
    final AlertCondition alertCondition = streamService.getAlertCondition(stream, conditionId);
    final AlertConditionTestResponse testResultResponse = testAlertCondition(alertCondition);
    if (testResultResponse.error()) {
        return Response.status(400).entity(testResultResponse).build();
    } else {
        return Response.ok(testResultResponse).build();
    }
}
Also used : AlertConditionTestResponse(org.graylog2.rest.resources.streams.responses.AlertConditionTestResponse) AlertCondition(org.graylog2.plugin.alarms.AlertCondition) Stream(org.graylog2.plugin.streams.Stream) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) NoAuditEvent(org.graylog2.audit.jersey.NoAuditEvent)

Aggregations

Timed (com.codahale.metrics.annotation.Timed)1 ApiOperation (io.swagger.annotations.ApiOperation)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 NoAuditEvent (org.graylog2.audit.jersey.NoAuditEvent)1 AlertCondition (org.graylog2.plugin.alarms.AlertCondition)1 Stream (org.graylog2.plugin.streams.Stream)1 AlertConditionTestResponse (org.graylog2.rest.resources.streams.responses.AlertConditionTestResponse)1