Search in sources :

Example 1 with CollectorSummary

use of org.graylog.plugins.sidecar.rest.models.CollectorSummary in project graylog2-server by Graylog2.

the class CollectorResource method listSummary.

@GET
@Path("/summary")
@RequiresPermissions(SidecarRestPermissions.COLLECTORS_READ)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "List a summary of all collectors")
public CollectorSummaryResponse listSummary(@ApiParam(name = "page") @QueryParam("page") @DefaultValue("1") int page, @ApiParam(name = "per_page") @QueryParam("per_page") @DefaultValue("50") int perPage, @ApiParam(name = "query") @QueryParam("query") @DefaultValue("") String query, @ApiParam(name = "sort", value = "The field to sort the result on", required = true, allowableValues = "name,id,collector_id") @DefaultValue(Collector.FIELD_NAME) @QueryParam("sort") String sort, @ApiParam(name = "order", value = "The sort direction", allowableValues = "asc, desc") @DefaultValue("asc") @QueryParam("order") String order) {
    final SearchQuery searchQuery = searchQueryParser.parse(query);
    final PaginatedList<Collector> collectors = this.collectorService.findPaginated(searchQuery, page, perPage, sort, order);
    final long total = this.collectorService.count();
    final List<CollectorSummary> summaries = collectors.stream().map(CollectorSummary::create).collect(Collectors.toList());
    return CollectorSummaryResponse.create(query, collectors.pagination(), total, sort, order, summaries);
}
Also used : SearchQuery(org.graylog2.search.SearchQuery) Collector(org.graylog.plugins.sidecar.rest.models.Collector) CollectorSummary(org.graylog.plugins.sidecar.rest.models.CollectorSummary) Path(javax.ws.rs.Path) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)1 Collector (org.graylog.plugins.sidecar.rest.models.Collector)1 CollectorSummary (org.graylog.plugins.sidecar.rest.models.CollectorSummary)1 SearchQuery (org.graylog2.search.SearchQuery)1