use of org.graylog2.audit.jersey.AuditEvent in project graylog2-server by Graylog2.
the class InputsResource method terminate.
@DELETE
@Timed
@Path("/{inputId}")
@ApiOperation(value = "Terminate input on this node")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No such input on this node.") })
@AuditEvent(type = AuditEventTypes.MESSAGE_INPUT_DELETE)
public void terminate(@ApiParam(name = "inputId", required = true) @PathParam("inputId") String inputId) throws org.graylog2.database.NotFoundException {
checkPermission(RestPermissions.INPUTS_TERMINATE, inputId);
final Input input = inputService.find(inputId);
inputService.destroy(input);
}
use of org.graylog2.audit.jersey.AuditEvent in project graylog2-server by Graylog2.
the class InputsResource method update.
@PUT
@Timed
@Path("/{inputId}")
@ApiOperation(value = "Update input on this node", response = InputCreated.class)
@ApiResponses(value = { @ApiResponse(code = 404, message = "No such input on this node."), @ApiResponse(code = 400, message = "Missing or invalid input configuration.") })
@AuditEvent(type = AuditEventTypes.MESSAGE_INPUT_UPDATE)
public Response update(@ApiParam(name = "JSON body", required = true) @Valid @NotNull InputCreateRequest lr, @ApiParam(name = "inputId", required = true) @PathParam("inputId") String inputId) throws org.graylog2.database.NotFoundException, NoSuchInputTypeException, ConfigurationException, ValidationException {
checkPermission(RestPermissions.INPUTS_EDIT, inputId);
final Input input = inputService.find(inputId);
final Map<String, Object> mergedInput = input.getFields();
final MessageInput messageInput = messageInputFactory.create(lr, getCurrentUser().getName(), lr.node());
messageInput.checkConfiguration();
mergedInput.putAll(messageInput.asMap());
final Input newInput = inputService.create(input.getId(), mergedInput);
inputService.update(newInput);
final URI inputUri = getUriBuilderToSelf().path(InputsResource.class).path("{inputId}").build(input.getId());
return Response.created(inputUri).entity(InputCreated.create(input.getId())).build();
}
use of org.graylog2.audit.jersey.AuditEvent in project graylog2-server by Graylog2.
the class LoggersResource method setSingleLoggerLevel.
@PUT
@Timed
@ApiOperation(value = "Set the loglevel of a single logger", notes = "Provided level is falling back to DEBUG if it does not exist")
@Path("/{loggerName}/level/{level}")
@AuditEvent(type = AuditEventTypes.LOG_LEVEL_UPDATE)
public void setSingleLoggerLevel(@ApiParam(name = "loggerName", required = true) @PathParam("loggerName") @NotEmpty String loggerName, @ApiParam(name = "level", required = true) @NotEmpty @PathParam("level") String level) {
checkPermission(RestPermissions.LOGGERS_EDIT, loggerName);
final Level newLevel = Level.toLevel(level.toUpperCase(Locale.ENGLISH));
setLoggerLevel(loggerName, newLevel);
LOG.debug("Successfully set log level for logger \"{}\" to \"{}\"", loggerName, newLevel);
}
use of org.graylog2.audit.jersey.AuditEvent in project graylog2-server by Graylog2.
the class LookupTableResource method updateTable.
@PUT
@Path("tables/{idOrName}")
@AuditEvent(type = AuditEventTypes.LOOKUP_TABLE_UPDATE)
@ApiOperation(value = "Update the given lookup table")
public LookupTableApi updateTable(@ApiParam(name = "idOrName") @PathParam("idOrName") @NotEmpty String idOrName, @Valid @ApiParam LookupTableApi toUpdate) {
checkLookupTableId(idOrName, toUpdate);
checkPermission(RestPermissions.LOOKUP_TABLES_EDIT, toUpdate.id());
LookupTableDto saved = dbTableService.save(toUpdate.toDto());
return LookupTableApi.fromDto(saved);
}
use of org.graylog2.audit.jersey.AuditEvent in project graylog2-server by Graylog2.
the class LookupTableResource method createAdapter.
@POST
@Path("adapters")
@AuditEvent(type = AuditEventTypes.LOOKUP_ADAPTER_CREATE)
@ApiOperation(value = "Create a new data adapter")
@RequiresPermissions(RestPermissions.LOOKUP_TABLES_CREATE)
public DataAdapterApi createAdapter(@Valid @ApiParam DataAdapterApi newAdapter) {
try {
DataAdapterDto dto = newAdapter.toDto();
DataAdapterDto saved = dbDataAdapterService.save(dto);
return DataAdapterApi.fromDto(saved);
} catch (DuplicateKeyException e) {
throw new BadRequestException(e.getMessage());
}
}
Aggregations