@POST
    @Consumes(MediaType.TEXT_PLAIN)
    @Timed
    @ApiOperation("Add a list of new patterns")
    @AuditEvent(type = AuditEventTypes.GROK_PATTERN_IMPORT_CREATE)
    public Response bulkUpdatePatternsFromTextFile(@ApiParam(name = "patterns", required = true) @NotNull InputStream patternsFile,
                                                   // deprecated. used to drop all existing patterns before import
                                                   @Deprecated @QueryParam("replace") @DefaultValue("false")
                                                   boolean deprecatedDropAllExisting,
                                                   @ApiParam(name = "import-strategy", value = "Strategy to apply when importing.")
                                                   @QueryParam("import-strategy")
                                                   ImportStrategy importStrategy) throws ValidationException, IOException {
        checkPermission(RestPermissions.INPUTS_CREATE);

        final List<GrokPattern> grokPatterns = readGrokPatterns(patternsFile);

        if (!grokPatterns.isEmpty()) {
            try {
                if (!grokPatternService.validateAll(grokPatterns)) {
                    throw new ValidationException("Invalid pattern contained. Did not save any patterns.");
                }
            } catch (GrokException | IllegalArgumentException e) {
                throw new ValidationException("Invalid pattern. Did not save any patterns\n" + e.getMessage());
            }

            ImportStrategy resolvedStrategy = importStrategy != null ? importStrategy :
                    deprecatedDropAllExisting ? ImportStrategy.DROP_ALL_EXISTING : ImportStrategy.ABORT_ON_CONFLICT;

            grokPatternService.saveAll(grokPatterns, resolvedStrategy);
        }

        return Response.accepted().build();
    }
@Test
    public void bulkUpdatePatternsFromTextFileWithLF() throws Exception {
        final String patterns = Arrays.stream(GROK_LINES).collect(Collectors.joining("\n"));
        final ByteArrayInputStream inputStream = new ByteArrayInputStream(patterns.getBytes(StandardCharsets.UTF_8));
        final GrokPattern expectedPattern = GrokPattern.create("TEST_PATTERN_0", "Foo");

        final Response response = grokResource.bulkUpdatePatternsFromTextFile(inputStream, true, null);

        assertThat(response.getStatusInfo()).isEqualTo(Response.Status.ACCEPTED);
        assertThat(response.hasEntity()).isFalse();

        await()
                .atMost(Durations.FIVE_SECONDS)
                .until(() -> !subscriber.events.isEmpty());
        assertThat(subscriber.events)
                .containsOnly(GrokPatternsUpdatedEvent.create(Collections.singleton(expectedPattern.name())));
    }