use of javax.ws.rs.PUT 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 {
inputService.find(inputId);
final InputCreated result = InputCreated.create(inputId);
this.serverEventBus.post(result);
return result;
}
use of javax.ws.rs.PUT 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.save(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 javax.ws.rs.PUT in project graylog2-server by Graylog2.
the class LdapResource method updateGroupMappingSettings.
@PUT
@RequiresPermissions(value = { RestPermissions.LDAPGROUPS_EDIT, RestPermissions.LDAP_EDIT }, logical = OR)
@ApiOperation(value = "Update the LDAP group to Graylog role mapping", notes = "Corresponds directly to the output of GET /system/ldap/settings/groups")
@Path("/settings/groups")
@Consumes(MediaType.APPLICATION_JSON)
@AuditEvent(type = AuditEventTypes.LDAP_GROUP_MAPPING_UPDATE)
public Response updateGroupMappingSettings(@ApiParam(name = "JSON body", required = true, value = "A hash in which the keys are the LDAP group names and values is the Graylog role name.") @NotNull Map<String, String> groupMapping) throws ValidationException {
final LdapSettings ldapSettings = firstNonNull(ldapSettingsService.load(), ldapSettingsFactory.createEmpty());
ldapSettings.setGroupMapping(groupMapping);
ldapSettingsService.save(ldapSettings);
return Response.noContent().build();
}
use of javax.ws.rs.PUT in project graylog2-server by Graylog2.
the class RotationStrategyResource method config.
@PUT
@Path("config")
@Consumes(MediaType.APPLICATION_JSON)
@Timed
@ApiOperation(value = "Configuration of the current rotation strategy", notes = "This resource stores the configuration of the currently used rotation strategy.")
@AuditEvent(type = AuditEventTypes.ES_INDEX_ROTATION_STRATEGY_UPDATE)
public RotationStrategySummary config(@ApiParam(value = "The description of the rotation strategy and its configuration", required = true) @Valid @NotNull RotationStrategySummary rotationStrategySummary) {
if (!rotationStrategies.containsKey(rotationStrategySummary.strategy())) {
throw new NotFoundException("Couldn't find rotation strategy for given type " + rotationStrategySummary.strategy());
}
final IndexManagementConfig oldConfig = clusterConfigService.get(IndexManagementConfig.class);
if (oldConfig == null) {
throw new InternalServerErrorException("Couldn't retrieve index management configuration");
}
final IndexManagementConfig indexManagementConfig = IndexManagementConfig.create(rotationStrategySummary.strategy(), oldConfig.retentionStrategy());
clusterConfigService.write(rotationStrategySummary.config());
clusterConfigService.write(indexManagementConfig);
return rotationStrategySummary;
}
use of javax.ws.rs.PUT 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 = userService.load(username);
checkPermission(RestPermissions.USERS_EDIT, username);
if (user == null) {
throw new NotFoundException("Couldn't find user " + username);
}
user.setPreferences(preferencesRequest.preferences());
userService.save(user);
}
Aggregations