Search in sources :

Example 1 with ValidationRequest

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));
}
Also used : ValidationResponse(org.graylog.plugins.views.search.validation.ValidationResponse) ValidationRequest(org.graylog.plugins.views.search.validation.ValidationRequest) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) NoAuditEvent(org.graylog2.audit.jersey.NoAuditEvent)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)1 POST (javax.ws.rs.POST)1 Produces (javax.ws.rs.Produces)1 ValidationRequest (org.graylog.plugins.views.search.validation.ValidationRequest)1 ValidationResponse (org.graylog.plugins.views.search.validation.ValidationResponse)1 NoAuditEvent (org.graylog2.audit.jersey.NoAuditEvent)1