Search in sources :

Example 1 with ResultFormat

use of org.graylog.plugins.views.search.export.ResultFormat in project graylog2-server by Graylog2.

the class MessagesResource method retrieveForSearch.

@ApiOperation(value = "Export a search result as CSV")
@POST
@Path("{searchId}")
@Produces(MoreMediaTypes.TEXT_CSV)
@NoAuditEvent("Has custom audit events")
public ChunkedOutput<SimpleMessageChunk> retrieveForSearch(@ApiParam(value = "ID of an existing Search", name = "searchId") @PathParam("searchId") String searchId, @ApiParam(value = "Optional overrides") @Valid ResultFormat formatFromClient, @Context SearchUser searchUser) {
    ResultFormat format = fillInIfNecessary(emptyIfNull(formatFromClient), searchUser);
    Search search = loadSearch(searchId, format.executionState(), searchUser);
    ExportMessagesCommand command = commandFactory.buildWithSearchOnly(search, format);
    return asyncRunner.apply(chunkConsumer -> exporter(searchId).export(command, chunkConsumer));
}
Also used : Search(org.graylog.plugins.views.search.Search) ResultFormat(org.graylog.plugins.views.search.export.ResultFormat) ExportMessagesCommand(org.graylog.plugins.views.search.export.ExportMessagesCommand) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) NoAuditEvent(org.graylog2.audit.jersey.NoAuditEvent)

Example 2 with ResultFormat

use of org.graylog.plugins.views.search.export.ResultFormat in project graylog2-server by Graylog2.

the class MessagesResource method retrieveForSearchType.

@ApiOperation(value = "Export a message table as CSV")
@POST
@Path("{searchId}/{searchTypeId}")
@NoAuditEvent("Has custom audit events")
public ChunkedOutput<SimpleMessageChunk> retrieveForSearchType(@ApiParam(value = "ID of an existing Search", name = "searchId") @PathParam("searchId") String searchId, @ApiParam(value = "ID of a Message Table contained in the Search", name = "searchTypeId") @PathParam("searchTypeId") String searchTypeId, @ApiParam(value = "Optional overrides") @Valid ResultFormat formatFromClient, @Context SearchUser searchUser) {
    ResultFormat format = fillInIfNecessary(emptyIfNull(formatFromClient), searchUser);
    Search search = loadSearch(searchId, format.executionState(), searchUser);
    ExportMessagesCommand command = commandFactory.buildWithMessageList(search, searchTypeId, format);
    return asyncRunner.apply(chunkConsumer -> exporter(searchId, searchTypeId).export(command, chunkConsumer));
}
Also used : Search(org.graylog.plugins.views.search.Search) ResultFormat(org.graylog.plugins.views.search.export.ResultFormat) ExportMessagesCommand(org.graylog.plugins.views.search.export.ExportMessagesCommand) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) ApiOperation(io.swagger.annotations.ApiOperation) NoAuditEvent(org.graylog2.audit.jersey.NoAuditEvent)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)2 POST (javax.ws.rs.POST)2 Path (javax.ws.rs.Path)2 Search (org.graylog.plugins.views.search.Search)2 ExportMessagesCommand (org.graylog.plugins.views.search.export.ExportMessagesCommand)2 ResultFormat (org.graylog.plugins.views.search.export.ResultFormat)2 NoAuditEvent (org.graylog2.audit.jersey.NoAuditEvent)2 Produces (javax.ws.rs.Produces)1