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();
}
}
Aggregations