Update ingest POST endpoint to accept the new processor schema
This commit is contained in:
parent
98f9f53008
commit
2c32d9fc3f
6 changed files with 29 additions and 19 deletions
|
@ -0,0 +1,10 @@
|
|||
import _ from 'lodash';
|
||||
import * as ingestProcessorApiKibanaToEsConverters from './ingest_processor_api_kibana_to_es_converters';
|
||||
|
||||
export default function ingestPipelineApiKibanaToEsConverter(pipelineApiDocument) {
|
||||
return {
|
||||
processors: _.map(pipelineApiDocument, (processor) => {
|
||||
return ingestProcessorApiKibanaToEsConverters[processor.type_id](processor);
|
||||
})
|
||||
};
|
||||
}
|
|
@ -1,13 +1,9 @@
|
|||
import _ from 'lodash';
|
||||
import * as ingestProcessorApiKibanaToEsConverters from './ingest_processor_api_kibana_to_es_converters';
|
||||
import ingestPipelineApiKibanaToEsConverter from './ingest_pipeline_api_kibana_to_es_converter';
|
||||
|
||||
export default function ingestSimulateApiKibanaToEsConverter(simulateApiDocument) {
|
||||
return {
|
||||
pipeline: {
|
||||
processors: _.map(simulateApiDocument.processors, (processor) => {
|
||||
return ingestProcessorApiKibanaToEsConverters[processor.type_id](processor);
|
||||
})
|
||||
},
|
||||
pipeline: ingestPipelineApiKibanaToEsConverter(simulateApiDocument.processors),
|
||||
docs: [
|
||||
{
|
||||
_source: simulateApiDocument.input
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
const Joi = require('joi');
|
||||
import _ from 'lodash';
|
||||
import Joi from 'joi';
|
||||
import * as ingestProcessorSchemas from './ingest_processor_schemas';
|
||||
|
||||
module.exports = Joi.array().items(Joi.object());
|
||||
module.exports = Joi.array().items(_.values(ingestProcessorSchemas));
|
||||
|
|
|
@ -6,6 +6,7 @@ import createMappingsFromPatternFields from '../../../lib/create_mappings_from_p
|
|||
import initDefaultFieldProps from '../../../lib/init_default_field_props';
|
||||
import {ingestToPattern, patternToIngest} from '../../../../common/lib/convert_pattern_and_ingest_name';
|
||||
import { keysToCamelCaseShallow } from '../../../../common/lib/case_conversion';
|
||||
import ingestPipelineApiKibanaToEsConverter from '../../../lib/converters/ingest_pipeline_api_kibana_to_es_converter';
|
||||
|
||||
module.exports = function registerPost(server) {
|
||||
const kibanaIndex = server.config().get('kibana.index');
|
||||
|
@ -77,9 +78,7 @@ module.exports = function registerPost(server) {
|
|||
indexPattern.fields = JSON.stringify(indexPattern.fields);
|
||||
indexPattern.fieldFormatMap = JSON.stringify(indexPattern.fieldFormatMap);
|
||||
|
||||
const pipeline = {
|
||||
processors: requestDocument.pipeline
|
||||
};
|
||||
const pipeline = ingestPipelineApiKibanaToEsConverter(requestDocument.pipeline);
|
||||
|
||||
// Set up call with request params
|
||||
const patternCreateParams = {
|
||||
|
|
|
@ -38,6 +38,11 @@ define(function (require) {
|
|||
// Fields must have a name and type
|
||||
request.post('/kibana/ingest')
|
||||
.send(_.set(createTestData(), 'index_pattern.fields', [{count: 0}]))
|
||||
.expect(400),
|
||||
|
||||
// should validate pipeline processors
|
||||
request.post('/kibana/ingest')
|
||||
.send(_.set(createTestData(), 'pipeline[0]', {bad: 'processor'}))
|
||||
.expect(400)
|
||||
]);
|
||||
});
|
||||
|
|
|
@ -24,13 +24,11 @@ module.exports = function createTestData() {
|
|||
}
|
||||
]
|
||||
},
|
||||
pipeline: [
|
||||
{
|
||||
date: {
|
||||
match_field: 'initialDate',
|
||||
match_formats: ['dd/MM/yyyy hh:mm:ss']
|
||||
}
|
||||
}
|
||||
]
|
||||
pipeline: [{
|
||||
processor_id: 'processor1',
|
||||
type_id: 'set',
|
||||
target_field: 'foo',
|
||||
value: 'bar'
|
||||
}]
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue