Search in sources :

Example 1 with ConfigurationSummary

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

the class ConfigurationResource method listConfigurations.

@GET
@RequiresPermissions(SidecarRestPermissions.CONFIGURATIONS_READ)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "List all configurations")
public ConfigurationListResponse listConfigurations(@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(Configuration.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<Configuration> configurations = this.configurationService.findPaginated(searchQuery, page, perPage, sort, order);
    final long total = this.configurationService.count();
    final List<ConfigurationSummary> result = configurations.stream().map(ConfigurationSummary::create).collect(Collectors.toList());
    return ConfigurationListResponse.create(query, configurations.pagination(), total, sort, order, result);
}
Also used : SearchQuery(org.graylog2.search.SearchQuery) Configuration(org.graylog.plugins.sidecar.rest.models.Configuration) ConfigurationSummary(org.graylog.plugins.sidecar.rest.models.ConfigurationSummary) 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 Produces (javax.ws.rs.Produces)1 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)1 Configuration (org.graylog.plugins.sidecar.rest.models.Configuration)1 ConfigurationSummary (org.graylog.plugins.sidecar.rest.models.ConfigurationSummary)1 SearchQuery (org.graylog2.search.SearchQuery)1