use of org.graylog.plugins.views.search.validation.ValidationRequest in project graylog2-server by Graylog2.
the class QueryValidationResource method validateQuery.
@POST
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Validate a search query")
@NoAuditEvent("Only validating query structure, not changing any data")
public ValidationResponseDTO validateQuery(@ApiParam(name = "validationRequest") ValidationRequestDTO validationRequest, @Context SearchUser searchUser) {
final ValidationRequest.Builder q = ValidationRequest.Builder.builder().query(validationRequest.query()).timerange(validationRequest.timerange().orElse(defaultTimeRange())).streams(searchUser.streams().readableOrAllIfEmpty(validationRequest.streams())).parameters(resolveParameters(validationRequest));
validationRequest.filter().ifPresent(q::filter);
final ValidationResponse response = queryValidationService.validate(q.build());
return ValidationResponseDTO.create(toStatus(response.status()), toExplanations(response));
}
Aggregations