use of org.graylog2.shared.inputs.InputDescription in project graylog2-server by Graylog2.
the class InputTypesResource method info.
@GET
@Timed
@Path("{inputType}")
@ApiOperation(value = "Get information about a single input type")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No such input type registered.") })
public InputTypeInfo info(@ApiParam(name = "inputType", required = true) @PathParam("inputType") String inputType) {
final InputDescription description = messageInputFactory.getAvailableInputs().get(inputType);
if (description == null) {
final String message = "Unknown input type " + inputType + " requested.";
LOG.error(message);
throw new NotFoundException(message);
}
return InputTypeInfo.create(inputType, description.getName(), description.isExclusive(), description.getRequestedConfiguration(), description.getLinkToDocs());
}
use of org.graylog2.shared.inputs.InputDescription in project graylog2-server by Graylog2.
the class BundleImporter method createMessageInput.
private MessageInput createMessageInput(final String bundleId, final Input inputDescription, final String userName) throws NoSuchInputTypeException, ConfigurationException, ValidationException, NotFoundException, org.graylog2.ConfigurationException, ExtractorFactory.NoSuchExtractorException, org.graylog2.plugin.inputs.Extractor.ReservedFieldException {
final Configuration inputConfig = new Configuration(inputDescription.getConfiguration());
final DateTime createdAt = Tools.nowUTC();
final MessageInput messageInput = messageInputFactory.create(inputDescription.getType(), inputConfig);
messageInput.setTitle(inputDescription.getTitle());
messageInput.setGlobal(inputDescription.isGlobal());
messageInput.setCreatorUserId(userName);
messageInput.setCreatedAt(createdAt);
messageInput.setContentPack(bundleId);
messageInput.checkConfiguration();
// Don't run if exclusive and another instance is already running.
if (messageInput.isExclusive() && inputRegistry.hasTypeRunning(messageInput.getClass())) {
LOG.error("Input type <{}> of input <{}> is exclusive and already has input running.", messageInput.getClass(), messageInput.getTitle());
}
final String id = inputDescription.getId();
final org.graylog2.inputs.Input mongoInput;
if (id == null) {
mongoInput = inputService.create(buildMongoDbInput(inputDescription, userName, createdAt, bundleId));
} else {
mongoInput = inputService.create(id, buildMongoDbInput(inputDescription, userName, createdAt, bundleId));
}
// Persist input.
final String persistId = inputService.save(mongoInput);
messageInput.setPersistId(persistId);
messageInput.initialize();
addStaticFields(messageInput, inputDescription.getStaticFields());
addExtractors(messageInput, inputDescription.getExtractors(), userName);
return messageInput;
}
use of org.graylog2.shared.inputs.InputDescription in project graylog2-server by Graylog2.
the class InputsResource method getInputSummary.
private InputSummary getInputSummary(Input input) {
final InputDescription inputDescription = this.availableInputs.get(input.getType());
final String name = inputDescription != null ? inputDescription.getName() : "Unknown Input (" + input.getType() + ")";
return InputSummary.create(input.getTitle(), input.isGlobal(), name, input.getContentPack(), input.getId(), input.getCreatedAt(), input.getType(), input.getCreatorUserId(), input.getConfiguration(), input.getStaticFields(), input.getNodeId());
}
Aggregations