Skip to content

Commit

Permalink
documented streams REST APIs #241
Browse files Browse the repository at this point in the history
  • Loading branch information
Lennart Koopmann committed Sep 23, 2013
1 parent 52e35af commit 45c63ab
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.graylog2.database.NotFoundException;
import org.graylog2.database.ValidationException;
import org.graylog2.plugin.streams.Stream;
import org.graylog2.rest.documentation.annotations.*;
import org.graylog2.rest.resources.RestResource;
import org.graylog2.rest.resources.streams.requests.CreateRequest;
import org.graylog2.streams.StreamImpl;
Expand All @@ -44,12 +45,13 @@
/**
* @author Lennart Koopmann <lennart@torch.sh>
*/
@Api(value = "Streams", description = "Manage streams")
@Path("/streams")
public class StreamResource extends RestResource {
private static final Logger LOG = LoggerFactory.getLogger(StreamResource.class);

@POST
@Timed
@POST @Timed
@ApiOperation(value = "Create a stream")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response create(String body) {
Expand Down Expand Up @@ -82,8 +84,8 @@ public Response create(String body) {
return Response.status(Response.Status.CREATED).entity(json(result)).build();
}

@GET
@Timed
@GET @Timed
@ApiOperation(value = "Get a list of all streams")
@Produces(MediaType.APPLICATION_JSON)
public String get() {
List<Map<String, Object>> streams = Lists.newArrayList();
Expand All @@ -99,8 +101,13 @@ public String get() {
}

@GET @Path("/{streamId}") @Timed
@ApiOperation(value = "Get a single stream")
@Produces(MediaType.APPLICATION_JSON)
public String get(@PathParam("streamId") String streamId) {
@ApiResponses(value = {
@ApiResponse(code = 404, message = "Stream not found."),
@ApiResponse(code = 400, message = "Invalid ObjectId.")
})
public String get(@ApiParam(title = "streamId", required = true) @PathParam("streamId") String streamId) {
if (streamId == null || streamId.isEmpty()) {
LOG.error("Missing streamId. Returning HTTP 400.");
throw new WebApplicationException(400);
Expand All @@ -117,7 +124,12 @@ public String get(@PathParam("streamId") String streamId) {
}

@DELETE @Path("/{streamId}") @Timed
public Response delete(@PathParam("streamId") String streamId) {
@ApiOperation(value = "Delete a stream")
@ApiResponses(value = {
@ApiResponse(code = 404, message = "Stream not found."),
@ApiResponse(code = 400, message = "Invalid ObjectId.")
})
public Response delete(@ApiParam(title = "streamId", required = true) @PathParam("streamId") String streamId) {
if (streamId == null || streamId.isEmpty()) {
LOG.error("Missing streamId. Returning HTTP 400.");
throw new WebApplicationException(400);
Expand Down

0 comments on commit 45c63ab

Please sign in to comment.