Search in sources :

Example 1 with InputDescription

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());
}
Also used : NotFoundException(javax.ws.rs.NotFoundException) InputDescription(org.graylog2.shared.inputs.InputDescription) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 2 with InputDescription

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;
}
Also used : Configuration(org.graylog2.plugin.configuration.Configuration) MessageInput(org.graylog2.plugin.inputs.MessageInput) DateTime(org.joda.time.DateTime)

Example 3 with InputDescription

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());
}
Also used : InputDescription(org.graylog2.shared.inputs.InputDescription)

Aggregations

InputDescription (org.graylog2.shared.inputs.InputDescription)2 Timed (com.codahale.metrics.annotation.Timed)1 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 GET (javax.ws.rs.GET)1 NotFoundException (javax.ws.rs.NotFoundException)1 Path (javax.ws.rs.Path)1 Configuration (org.graylog2.plugin.configuration.Configuration)1 MessageInput (org.graylog2.plugin.inputs.MessageInput)1 DateTime (org.joda.time.DateTime)1