Search in sources :

Example 1 with AlertConditionListSummary

use of org.graylog2.rest.models.streams.alerts.AlertConditionListSummary in project graylog2-server by Graylog2.

the class StreamAlertConditionResource method list.

@GET
@Timed
@ApiOperation(value = "Get all alert conditions of this stream")
@ApiResponses(value = { @ApiResponse(code = 404, message = "Stream not found."), @ApiResponse(code = 400, message = "Invalid ObjectId.") })
public AlertConditionListSummary list(@ApiParam(name = "streamId", value = "The stream id this new alert condition belongs to.", required = true) @PathParam("streamId") String streamid) throws NotFoundException {
    checkPermission(RestPermissions.STREAMS_READ, streamid);
    final Stream stream = streamService.load(streamid);
    final List<AlertCondition> alertConditions = streamService.getAlertConditions(stream);
    final List<AlertConditionSummary> conditionSummaries = alertConditions.stream().map((condition) -> AlertConditionSummary.create(condition.getId(), condition.getType(), condition.getCreatorUserId(), condition.getCreatedAt().toDate(), condition.getParameters(), alertService.inGracePeriod(condition), condition.getTitle())).collect(Collectors.toList());
    return AlertConditionListSummary.create(conditionSummaries);
}
Also used : PathParam(javax.ws.rs.PathParam) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Path(javax.ws.rs.Path) ApiParam(io.swagger.annotations.ApiParam) ApiResponses(io.swagger.annotations.ApiResponses) AlertService(org.graylog2.alerts.AlertService) Inject(javax.inject.Inject) Valid(javax.validation.Valid) ApiOperation(io.swagger.annotations.ApiOperation) MediaType(javax.ws.rs.core.MediaType) Consumes(javax.ws.rs.Consumes) AlertConditionSummary(org.graylog2.rest.models.streams.alerts.AlertConditionSummary) ConfigurationException(org.graylog2.plugin.configuration.ConfigurationException) Map(java.util.Map) AuditEvent(org.graylog2.audit.jersey.AuditEvent) BadRequestException(javax.ws.rs.BadRequestException) Api(io.swagger.annotations.Api) URI(java.net.URI) NotFoundException(org.graylog2.database.NotFoundException) DELETE(javax.ws.rs.DELETE) ConfigurationRequest(org.graylog2.plugin.configuration.ConfigurationRequest) POST(javax.ws.rs.POST) ConfigurationMapConverter(org.graylog2.utilities.ConfigurationMapConverter) ImmutableMap(com.google.common.collect.ImmutableMap) AlertConditionListSummary(org.graylog2.rest.models.streams.alerts.AlertConditionListSummary) RestResource(org.graylog2.shared.rest.resources.RestResource) NotNull(javax.validation.constraints.NotNull) Collectors(java.util.stream.Collectors) Timed(com.codahale.metrics.annotation.Timed) List(java.util.List) Response(javax.ws.rs.core.Response) Stream(org.graylog2.plugin.streams.Stream) ApiResponse(io.swagger.annotations.ApiResponse) AuditEventTypes(org.graylog2.audit.AuditEventTypes) ValidationException(org.graylog2.plugin.database.ValidationException) RestPermissions(org.graylog2.shared.security.RestPermissions) StreamService(org.graylog2.streams.StreamService) AlertCondition(org.graylog2.plugin.alarms.AlertCondition) CreateConditionRequest(org.graylog2.rest.models.streams.alerts.requests.CreateConditionRequest) PUT(javax.ws.rs.PUT) RequiresAuthentication(org.apache.shiro.authz.annotation.RequiresAuthentication) AlertCondition(org.graylog2.plugin.alarms.AlertCondition) Stream(org.graylog2.plugin.streams.Stream) AlertConditionSummary(org.graylog2.rest.models.streams.alerts.AlertConditionSummary) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

Timed (com.codahale.metrics.annotation.Timed)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Api (io.swagger.annotations.Api)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiParam (io.swagger.annotations.ApiParam)1 ApiResponse (io.swagger.annotations.ApiResponse)1 ApiResponses (io.swagger.annotations.ApiResponses)1 URI (java.net.URI)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 Valid (javax.validation.Valid)1 NotNull (javax.validation.constraints.NotNull)1 BadRequestException (javax.ws.rs.BadRequestException)1 Consumes (javax.ws.rs.Consumes)1 DELETE (javax.ws.rs.DELETE)1 GET (javax.ws.rs.GET)1 POST (javax.ws.rs.POST)1 PUT (javax.ws.rs.PUT)1