Search in sources :

Example 1 with StreamListResponse

use of org.graylog2.rest.resources.streams.responses.StreamListResponse in project graylog2-server by Graylog2.

the class StreamResource method getEnabled.

@GET
@Path("/enabled")
@Timed
@ApiOperation(value = "Get a list of all enabled streams")
@Produces(MediaType.APPLICATION_JSON)
public StreamListResponse getEnabled() throws NotFoundException {
    final List<Stream> enabledStreams = streamService.loadAllEnabled();
    final List<Stream> streams = new ArrayList<>(enabledStreams.size());
    for (Stream stream : enabledStreams) {
        if (isPermitted(RestPermissions.STREAMS_READ, stream.getId())) {
            streams.add(stream);
        }
    }
    return StreamListResponse.create(streams.size(), streams.stream().map(this::streamToResponse).collect(Collectors.toSet()));
}
Also used : ArrayList(java.util.ArrayList) Stream(org.graylog2.plugin.streams.Stream) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with StreamListResponse

use of org.graylog2.rest.resources.streams.responses.StreamListResponse in project graylog2-server by Graylog2.

the class StreamResource method get.

@GET
@Timed
@ApiOperation(value = "Get a list of all streams")
@Deprecated
@Produces(MediaType.APPLICATION_JSON)
public StreamListResponse get() {
    final List<Stream> allStreams = streamService.loadAll();
    final List<Stream> streams = new ArrayList<>(allStreams.size());
    for (Stream stream : allStreams) {
        if (isPermitted(RestPermissions.STREAMS_READ, stream.getId())) {
            streams.add(stream);
        }
    }
    return StreamListResponse.create(streams.size(), streams.stream().map(this::streamToResponse).collect(Collectors.toSet()));
}
Also used : ArrayList(java.util.ArrayList) Stream(org.graylog2.plugin.streams.Stream) Produces(javax.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

Timed (com.codahale.metrics.annotation.Timed)2 ApiOperation (io.swagger.annotations.ApiOperation)2 ArrayList (java.util.ArrayList)2 GET (javax.ws.rs.GET)2 Produces (javax.ws.rs.Produces)2 Stream (org.graylog2.plugin.streams.Stream)2 Path (javax.ws.rs.Path)1