use of org.graylog2.audit.jersey.AuditEvent in project graylog2-server by Graylog2.
the class LookupTableResource method updateCache.
@PUT
@Path("caches/{idOrName}")
@AuditEvent(type = AuditEventTypes.LOOKUP_CACHE_UPDATE)
@ApiOperation(value = "Update the given cache settings")
public CacheApi updateCache(@ApiParam(name = "idOrName") @PathParam("idOrName") @NotEmpty String idOrName, @ApiParam CacheApi toUpdate) {
checkLookupCacheId(idOrName, toUpdate);
checkPermission(RestPermissions.LOOKUP_TABLES_EDIT, toUpdate.id());
CacheDto saved = dbCacheService.save(toUpdate.toDto());
return CacheApi.fromDto(saved);
}
use of org.graylog2.audit.jersey.AuditEvent in project graylog2-server by Graylog2.
the class UsersResource method savePreferences.
@PUT
@Path("{username}/preferences")
@ApiOperation("Update a user's preferences set.")
@ApiResponses({ @ApiResponse(code = 400, message = "Missing or invalid permission data.") })
@AuditEvent(type = AuditEventTypes.USER_PREFERENCES_UPDATE)
public void savePreferences(@ApiParam(name = "username", value = "The name of the user to modify.", required = true) @PathParam("username") String username, @ApiParam(name = "JSON body", value = "The map of preferences to assign to the user.", required = true) UpdateUserPreferences preferencesRequest) throws ValidationException {
final User user = userManagementService.load(username);
checkPermission(RestPermissions.USERS_EDIT, username);
if (user == null) {
throw new NotFoundException("Couldn't find user " + username);
}
user.setPreferences(preferencesRequest.preferences());
userManagementService.save(user);
}
use of org.graylog2.audit.jersey.AuditEvent in project graylog2-server by Graylog2.
the class UsersResource method updateAccountStatus.
@PUT
@Path("{userId}/status/{newStatus}")
@Consumes(MediaType.WILDCARD)
@ApiOperation("Update the account status for a user")
@AuditEvent(type = AuditEventTypes.USER_UPDATE)
public Response updateAccountStatus(@ApiParam(name = "userId", value = "The id of the user whose status to change.", required = true) @PathParam("userId") @NotBlank String userId, @ApiParam(name = "newStatus", value = "The account status to be set", required = true, defaultValue = "enabled", allowableValues = "enabled,disabled,deleted") @PathParam("newStatus") @NotBlank String newStatusString, @Context UserContext userContext) throws ValidationException {
if (userId.equalsIgnoreCase(userContext.getUserId())) {
throw new BadRequestException("Users are not allowed to set their own status");
}
final User.AccountStatus newStatus = User.AccountStatus.valueOf(newStatusString.toUpperCase(Locale.US));
final User user = loadUserById(userId);
checkPermission(RestPermissions.USERS_EDIT, user.getName());
final User.AccountStatus oldStatus = user.getAccountStatus();
if (oldStatus.equals(newStatus)) {
return Response.notModified().build();
}
userManagementService.setUserStatus(user, newStatus);
return Response.ok().build();
}
use of org.graylog2.audit.jersey.AuditEvent in project graylog2-server by Graylog2.
the class InputStatesResource method start.
@PUT
@Path("/{inputId}")
@Timed
@ApiOperation(value = "(Re-)Start specified input on this node")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No such input on this node.") })
@AuditEvent(type = AuditEventTypes.MESSAGE_INPUT_START)
public InputCreated start(@ApiParam(name = "inputId", required = true) @PathParam("inputId") String inputId) throws org.graylog2.database.NotFoundException {
checkPermission(RestPermissions.INPUTS_CHANGESTATE, inputId);
final Input input = inputService.find(inputId);
persistDesiredState(input, IOState.Type.RUNNING);
final InputCreated result = InputCreated.create(inputId);
this.serverEventBus.post(result);
return result;
}
use of org.graylog2.audit.jersey.AuditEvent in project graylog2-server by Graylog2.
the class OutputResource method delete.
@DELETE
@Path("/{outputId}")
@Timed
@ApiOperation(value = "Delete output")
@Produces(MediaType.APPLICATION_JSON)
@ApiResponses(value = { @ApiResponse(code = 404, message = "No such stream/output on this node.") })
@AuditEvent(type = AuditEventTypes.MESSAGE_OUTPUT_DELETE)
public void delete(@ApiParam(name = "outputId", value = "The id of the output that should be deleted", required = true) @PathParam("outputId") String outputId) throws org.graylog2.database.NotFoundException {
checkPermission(RestPermissions.OUTPUTS_TERMINATE);
final Output output = outputService.load(outputId);
outputService.destroy(output);
}
Aggregations