use of org.graylog.plugins.sidecar.rest.requests.BulkActionRequest in project graylog2-server by Graylog2.
the class AdministrationResource method setAction.
@PUT
@Timed
@Path("/action")
@RequiresPermissions(SidecarRestPermissions.SIDECARS_UPDATE)
@ApiOperation(value = "Set collector actions in bulk")
@ApiResponses(value = { @ApiResponse(code = 400, message = "The supplied action is not valid.") })
@AuditEvent(type = SidecarAuditEventTypes.ACTION_UPDATE)
public Response setAction(@ApiParam(name = "JSON body", required = true) @Valid @NotNull BulkActionsRequest request) {
for (BulkActionRequest bulkActionRequest : request.collectors()) {
final List<CollectorAction> actions = bulkActionRequest.collectorIds().stream().map(collectorId -> CollectorAction.create(collectorId, request.action())).collect(Collectors.toList());
final CollectorActions collectorActions = actionService.fromRequest(bulkActionRequest.sidecarId(), actions);
actionService.saveAction(collectorActions);
}
return Response.accepted().build();
}
Aggregations