From 0ab60c1a0cc5b3aedf89c8b15cc5a4654610c8d0 Mon Sep 17 00:00:00 2001 From: Alison Goryachev Date: Mon, 6 Apr 2020 16:54:50 -0400 Subject: [PATCH 1/5] add create/edit endpoints --- .../server/routes/api/create.ts | 81 +++++++++++++++++++ .../server/routes/api/index.ts | 4 + .../server/routes/api/update.ts | 68 ++++++++++++++++ .../ingest_pipelines/server/routes/index.ts | 4 +- 4 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 x-pack/plugins/ingest_pipelines/server/routes/api/create.ts create mode 100644 x-pack/plugins/ingest_pipelines/server/routes/api/update.ts diff --git a/x-pack/plugins/ingest_pipelines/server/routes/api/create.ts b/x-pack/plugins/ingest_pipelines/server/routes/api/create.ts new file mode 100644 index 0000000000000..568f0e3513752 --- /dev/null +++ b/x-pack/plugins/ingest_pipelines/server/routes/api/create.ts @@ -0,0 +1,81 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { i18n } from '@kbn/i18n'; +import { schema } from '@kbn/config-schema'; + +import { Pipeline } from '../../../common/types'; +import { API_BASE_PATH } from '../../../common/constants'; +import { RouteDependencies } from '../../types'; + +const bodySchema = schema.object({ + name: schema.string(), + description: schema.string(), + processors: schema.arrayOf(schema.any()), // todo fix + version: schema.maybe(schema.number()), +}); + +export const registerCreateRoute = ({ + router, + license, + lib: { isEsError }, +}: RouteDependencies): void => { + router.put( + { + path: API_BASE_PATH, + validate: { + body: bodySchema, + }, + }, + license.guardApiRoute(async (ctx, req, res) => { + const { callAsCurrentUser } = ctx.core.elasticsearch.dataClient; + const pipeline = req.body as Pipeline; + + const { name, description, processors, version } = pipeline; + + try { + // Check that a pipeline with the same name doesn't already exist + const pipelineByName = await callAsCurrentUser('ingest.getPipeline', { id: name }); + + if (pipelineByName[name]) { + return res.conflict({ + body: new Error( + i18n.translate('xpack.ingestPipelines.createRoute.duplicatePipelineIdErrorMessage', { + defaultMessage: "There is already a pipeline with name '{name}'.", + values: { + name, + }, + }) + ), + }); + } + } catch (e) { + // Silently swallow error + } + + try { + const response = await callAsCurrentUser('ingest.putPipeline', { + id: name, + body: { + description, + processors, + version, + }, + }); + + return res.ok({ body: response }); + } catch (error) { + if (isEsError(error)) { + return res.customError({ + statusCode: error.statusCode, + body: error, + }); + } + + return res.internalError({ body: error }); + } + }) + ); +}; diff --git a/x-pack/plugins/ingest_pipelines/server/routes/api/index.ts b/x-pack/plugins/ingest_pipelines/server/routes/api/index.ts index 28e327e6c2d3c..0d40d17205eed 100644 --- a/x-pack/plugins/ingest_pipelines/server/routes/api/index.ts +++ b/x-pack/plugins/ingest_pipelines/server/routes/api/index.ts @@ -5,3 +5,7 @@ */ export { registerGetRoutes } from './get'; + +export { registerCreateRoute } from './create'; + +export { registerUpdateRoute } from './update'; diff --git a/x-pack/plugins/ingest_pipelines/server/routes/api/update.ts b/x-pack/plugins/ingest_pipelines/server/routes/api/update.ts new file mode 100644 index 0000000000000..794845b33860d --- /dev/null +++ b/x-pack/plugins/ingest_pipelines/server/routes/api/update.ts @@ -0,0 +1,68 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { schema } from '@kbn/config-schema'; + +import { Pipeline } from '../../../common/types'; +import { API_BASE_PATH } from '../../../common/constants'; +import { RouteDependencies } from '../../types'; + +const bodySchema = schema.object({ + description: schema.string(), + processors: schema.arrayOf(schema.any()), // todo fix + version: schema.maybe(schema.number()), +}); + +const paramsSchema = schema.object({ + name: schema.string(), +}); + +export const registerUpdateRoute = ({ + router, + license, + lib: { isEsError }, +}: RouteDependencies): void => { + router.put( + { + path: `${API_BASE_PATH}/{name}`, + validate: { + body: bodySchema, + params: paramsSchema, + }, + }, + license.guardApiRoute(async (ctx, req, res) => { + const { callAsCurrentUser } = ctx.core.elasticsearch.dataClient; + const { name } = req.params as typeof paramsSchema.type; + const pipeline = req.body as Pipeline; + + const { description, processors, version } = pipeline; + + try { + // Verify pipeline exists + await callAsCurrentUser('ingest.getPipeline', { id: name }); + + const response = await callAsCurrentUser('ingest.putPipeline', { + id: name, + body: { + description, + processors, + version, + }, + }); + + return res.ok({ body: response }); + } catch (error) { + if (isEsError(error)) { + return res.customError({ + statusCode: error.statusCode, + body: error, + }); + } + + return res.internalError({ body: error }); + } + }) + ); +}; diff --git a/x-pack/plugins/ingest_pipelines/server/routes/index.ts b/x-pack/plugins/ingest_pipelines/server/routes/index.ts index b2c940a53f8f2..d217fb937778c 100644 --- a/x-pack/plugins/ingest_pipelines/server/routes/index.ts +++ b/x-pack/plugins/ingest_pipelines/server/routes/index.ts @@ -6,10 +6,12 @@ import { RouteDependencies } from '../types'; -import { registerGetRoutes } from './api'; +import { registerGetRoutes, registerCreateRoute, registerUpdateRoute } from './api'; export class ApiRoutes { setup(dependencies: RouteDependencies) { registerGetRoutes(dependencies); + registerCreateRoute(dependencies); + registerUpdateRoute(dependencies); } } From c93c07bd5d7b2383a1049e71d05884ef7b5d9062 Mon Sep 17 00:00:00 2001 From: Alison Goryachev Date: Tue, 7 Apr 2020 04:24:44 -0400 Subject: [PATCH 2/5] add api integration tests --- .../api_integration/apis/management/index.js | 1 + .../apis/management/ingest_pipelines/index.ts | 12 ++ .../ingest_pipelines/ingest_pipelines.ts | 127 ++++++++++++++++++ .../ingest_pipelines/lib/elasticsearch.ts | 41 ++++++ .../management/ingest_pipelines/lib/index.ts | 7 + 5 files changed, 188 insertions(+) create mode 100644 x-pack/test/api_integration/apis/management/ingest_pipelines/index.ts create mode 100644 x-pack/test/api_integration/apis/management/ingest_pipelines/ingest_pipelines.ts create mode 100644 x-pack/test/api_integration/apis/management/ingest_pipelines/lib/elasticsearch.ts create mode 100644 x-pack/test/api_integration/apis/management/ingest_pipelines/lib/index.ts diff --git a/x-pack/test/api_integration/apis/management/index.js b/x-pack/test/api_integration/apis/management/index.js index 352cd56d0fc9f..cef2caa918620 100644 --- a/x-pack/test/api_integration/apis/management/index.js +++ b/x-pack/test/api_integration/apis/management/index.js @@ -12,5 +12,6 @@ export default function({ loadTestFile }) { loadTestFile(require.resolve('./rollup')); loadTestFile(require.resolve('./index_management')); loadTestFile(require.resolve('./index_lifecycle_management')); + loadTestFile(require.resolve('./ingest_pipelines')); }); } diff --git a/x-pack/test/api_integration/apis/management/ingest_pipelines/index.ts b/x-pack/test/api_integration/apis/management/ingest_pipelines/index.ts new file mode 100644 index 0000000000000..ca222ebc2c1e3 --- /dev/null +++ b/x-pack/test/api_integration/apis/management/ingest_pipelines/index.ts @@ -0,0 +1,12 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { FtrProviderContext } from '../../../ftr_provider_context'; + +export default function({ loadTestFile }: FtrProviderContext) { + describe('Ingest Node Pipelines', () => { + loadTestFile(require.resolve('./ingest_pipelines')); + }); +} diff --git a/x-pack/test/api_integration/apis/management/ingest_pipelines/ingest_pipelines.ts b/x-pack/test/api_integration/apis/management/ingest_pipelines/ingest_pipelines.ts new file mode 100644 index 0000000000000..2ec58949c491b --- /dev/null +++ b/x-pack/test/api_integration/apis/management/ingest_pipelines/ingest_pipelines.ts @@ -0,0 +1,127 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import expect from '@kbn/expect'; +import { registerEsHelpers } from './lib'; + +import { FtrProviderContext } from '../../../ftr_provider_context'; + +const API_BASE_PATH = '/api/ingest_pipelines'; + +export default function({ getService }: FtrProviderContext) { + const supertest = getService('supertest'); + + const { createPipeline, deletePipeline } = registerEsHelpers(getService); + + describe('Pipelines', function() { + describe('Create', () => { + const PIPELINE_ID = 'test_create_pipeline'; + after(() => deletePipeline(PIPELINE_ID)); + + it('should create a pipeline', async () => { + const { body } = await supertest + .put(API_BASE_PATH) + .set('kbn-xsrf', 'xxx') + .send({ + name: PIPELINE_ID, + description: 'test pipeline description', + processors: [ + { + script: { + source: 'ctx._type = null', + }, + }, + ], + version: 1, + }) + .expect(200); + + expect(body).to.eql({ + acknowledged: true, + }); + }); + + it('should not allow creation of an existing pipeline', async () => { + const { body } = await supertest + .put(API_BASE_PATH) + .set('kbn-xsrf', 'xxx') + .send({ + name: PIPELINE_ID, + description: 'test pipeline description', + processors: [ + { + script: { + source: 'ctx._type = null', + }, + }, + ], + version: 1, + }) + .expect(409); + + expect(body).to.eql({ + statusCode: 409, + error: 'Conflict', + message: `There is already a pipeline with name '${PIPELINE_ID}'.`, + }); + }); + }); + + describe('Update', () => { + const PIPELINE_ID = 'test_update_pipeline'; + const PIPELINE = { + description: 'test pipeline description', + processors: [ + { + script: { + source: 'ctx._type = null', + }, + }, + ], + version: 1, + }; + + before(() => createPipeline({ body: PIPELINE, id: PIPELINE_ID })); + after(() => deletePipeline(PIPELINE_ID)); + + it('should allow an existing pipeline to be updated', async () => { + const uri = `${API_BASE_PATH}/${PIPELINE_ID}`; + + const { body } = await supertest + .put(uri) + .set('kbn-xsrf', 'xxx') + .send({ + ...PIPELINE, + description: 'updated test pipeline description', + }) + .expect(200); + + expect(body).to.eql({ + acknowledged: true, + }); + }); + + it('should not allow a non-existing pipeline to be updated', async () => { + const uri = `${API_BASE_PATH}/pipeline_does_not_exist`; + + const { body } = await supertest + .put(uri) + .set('kbn-xsrf', 'xxx') + .send({ + ...PIPELINE, + description: 'updated test pipeline description', + }) + .expect(404); + + expect(body).to.eql({ + statusCode: 404, + error: 'Not Found', + message: 'Not Found', + }); + }); + }); + }); +} diff --git a/x-pack/test/api_integration/apis/management/ingest_pipelines/lib/elasticsearch.ts b/x-pack/test/api_integration/apis/management/ingest_pipelines/lib/elasticsearch.ts new file mode 100644 index 0000000000000..3c87faa2ea9f0 --- /dev/null +++ b/x-pack/test/api_integration/apis/management/ingest_pipelines/lib/elasticsearch.ts @@ -0,0 +1,41 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import { FtrProviderContext } from '../../../../ftr_provider_context'; + +interface Pipeline { + id: string; + body: { + description: string; + processors: any[]; + version?: number; + }; +} + +/** + * Helpers to create and delete indices on the Elasticsearch instance + * during our tests. + * @param {ElasticsearchClient} es The Elasticsearch client instance + */ +export const registerEsHelpers = (getService: FtrProviderContext['getService']) => { + const es = getService('legacyEs'); + + let pipelinesCreated: Pipeline[] = []; + + const createPipeline = (pipeline: Pipeline) => { + pipelinesCreated.push(pipeline); + return es.ingest.putPipeline(pipeline).then(() => pipeline); + }; + + const deletePipeline = (pipelineId: string) => { + pipelinesCreated = pipelinesCreated.filter(({ id }) => id !== pipelineId); + return es.ingest.deletePipeline({ id: pipelineId }); + }; + + return { + createPipeline, + deletePipeline, + }; +}; diff --git a/x-pack/test/api_integration/apis/management/ingest_pipelines/lib/index.ts b/x-pack/test/api_integration/apis/management/ingest_pipelines/lib/index.ts new file mode 100644 index 0000000000000..66ea0fe40c4ce --- /dev/null +++ b/x-pack/test/api_integration/apis/management/ingest_pipelines/lib/index.ts @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export { registerEsHelpers } from './elasticsearch'; From edaf51529dbb1c9714d35607c0ee0d3c97b2d266 Mon Sep 17 00:00:00 2001 From: Alison Goryachev Date: Tue, 7 Apr 2020 10:16:19 -0400 Subject: [PATCH 3/5] cleanup --- .../server/routes/api/update.ts | 2 +- .../ingest_pipelines/lib/elasticsearch.ts | 22 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/x-pack/plugins/ingest_pipelines/server/routes/api/update.ts b/x-pack/plugins/ingest_pipelines/server/routes/api/update.ts index 794845b33860d..fa5ee440285f1 100644 --- a/x-pack/plugins/ingest_pipelines/server/routes/api/update.ts +++ b/x-pack/plugins/ingest_pipelines/server/routes/api/update.ts @@ -40,7 +40,7 @@ export const registerUpdateRoute = ({ const { description, processors, version } = pipeline; try { - // Verify pipeline exists + // Verify pipeline exists; ES will throw 404 if it doesn't await callAsCurrentUser('ingest.getPipeline', { id: name }); const response = await callAsCurrentUser('ingest.putPipeline', { diff --git a/x-pack/test/api_integration/apis/management/ingest_pipelines/lib/elasticsearch.ts b/x-pack/test/api_integration/apis/management/ingest_pipelines/lib/elasticsearch.ts index 3c87faa2ea9f0..2f42596a66b54 100644 --- a/x-pack/test/api_integration/apis/management/ingest_pipelines/lib/elasticsearch.ts +++ b/x-pack/test/api_integration/apis/management/ingest_pipelines/lib/elasticsearch.ts @@ -5,34 +5,32 @@ */ import { FtrProviderContext } from '../../../../ftr_provider_context'; +interface Processor { + [key: string]: { + [key: string]: unknown; + }; +} + interface Pipeline { id: string; body: { description: string; - processors: any[]; + processors: Processor[]; version?: number; }; } /** - * Helpers to create and delete indices on the Elasticsearch instance + * Helpers to create and delete pipelines on the Elasticsearch instance * during our tests. * @param {ElasticsearchClient} es The Elasticsearch client instance */ export const registerEsHelpers = (getService: FtrProviderContext['getService']) => { const es = getService('legacyEs'); - let pipelinesCreated: Pipeline[] = []; + const createPipeline = (pipeline: Pipeline) => es.ingest.putPipeline(pipeline); - const createPipeline = (pipeline: Pipeline) => { - pipelinesCreated.push(pipeline); - return es.ingest.putPipeline(pipeline).then(() => pipeline); - }; - - const deletePipeline = (pipelineId: string) => { - pipelinesCreated = pipelinesCreated.filter(({ id }) => id !== pipelineId); - return es.ingest.deletePipeline({ id: pipelineId }); - }; + const deletePipeline = (pipelineId: string) => es.ingest.deletePipeline({ id: pipelineId }); return { createPipeline, From 5d65c88adcdc4dc0beea6e03dc44ef60e18ab9ec Mon Sep 17 00:00:00 2001 From: Alison Goryachev Date: Tue, 7 Apr 2020 16:02:51 -0400 Subject: [PATCH 4/5] add support for on_failure parameter --- .../common/lib/pipeline_serialization.test.ts | 16 ++++++++++++++++ .../common/lib/pipeline_serialization.ts | 17 +++++++++++++---- x-pack/plugins/ingest_pipelines/common/types.ts | 8 +++++++- .../server/routes/api/create.ts | 6 ++++-- .../server/routes/api/update.ts | 6 ++++-- .../ingest_pipelines/ingest_pipelines.ts | 8 ++++++++ 6 files changed, 52 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/ingest_pipelines/common/lib/pipeline_serialization.test.ts b/x-pack/plugins/ingest_pipelines/common/lib/pipeline_serialization.test.ts index 5c6f22d0eff94..2e9147065ea15 100644 --- a/x-pack/plugins/ingest_pipelines/common/lib/pipeline_serialization.test.ts +++ b/x-pack/plugins/ingest_pipelines/common/lib/pipeline_serialization.test.ts @@ -20,6 +20,14 @@ describe('pipeline_serialization', () => { }, }, ], + on_failure: [ + { + set: { + field: 'error.message', + value: '{{ failure_message }}', + }, + }, + ], }, pipeline2: { description: 'pipeline2 description', @@ -39,6 +47,14 @@ describe('pipeline_serialization', () => { }, }, ], + onFailure: [ + { + set: { + field: 'error.message', + value: '{{ failure_message }}', + }, + }, + ], }, { name: 'pipeline2', diff --git a/x-pack/plugins/ingest_pipelines/common/lib/pipeline_serialization.ts b/x-pack/plugins/ingest_pipelines/common/lib/pipeline_serialization.ts index e137502d4dc37..11061d096c224 100644 --- a/x-pack/plugins/ingest_pipelines/common/lib/pipeline_serialization.ts +++ b/x-pack/plugins/ingest_pipelines/common/lib/pipeline_serialization.ts @@ -9,16 +9,25 @@ import { PipelinesByName, Pipeline } from '../types'; export function deserializePipelines(pipelinesByName: PipelinesByName): Pipeline[] { const pipelineNames: string[] = Object.keys(pipelinesByName); - const deserializedTemplates = pipelineNames.map((name: string) => { - const { description, version, processors } = pipelinesByName[name]; + const deserializedPipelines = pipelineNames.map((name: string) => { + const { description, version, processors, on_failure } = pipelinesByName[name]; - return { + const pipeline = { name, description, version, processors, + onFailure: on_failure, }; + + // Remove any undefined values + return Object.entries(pipeline).reduce((pipelineDefinition: any, [key, value]) => { + if (value !== undefined) { + pipelineDefinition[key] = value; + } + return pipelineDefinition; + }, {}); }); - return deserializedTemplates; + return deserializedPipelines; } diff --git a/x-pack/plugins/ingest_pipelines/common/types.ts b/x-pack/plugins/ingest_pipelines/common/types.ts index 383d170441581..6e02922a71018 100644 --- a/x-pack/plugins/ingest_pipelines/common/types.ts +++ b/x-pack/plugins/ingest_pipelines/common/types.ts @@ -15,8 +15,14 @@ export interface Pipeline { description: string; version?: number; processors: Processor[]; + onFailure?: Processor[]; } export interface PipelinesByName { - [key: string]: Omit; + [key: string]: { + description: string; + version?: number; + processors: Processor[]; + on_failure?: Processor[]; + }; } diff --git a/x-pack/plugins/ingest_pipelines/server/routes/api/create.ts b/x-pack/plugins/ingest_pipelines/server/routes/api/create.ts index 568f0e3513752..013681fa2f4b7 100644 --- a/x-pack/plugins/ingest_pipelines/server/routes/api/create.ts +++ b/x-pack/plugins/ingest_pipelines/server/routes/api/create.ts @@ -13,8 +13,9 @@ import { RouteDependencies } from '../../types'; const bodySchema = schema.object({ name: schema.string(), description: schema.string(), - processors: schema.arrayOf(schema.any()), // todo fix + processors: schema.arrayOf(schema.recordOf(schema.string(), schema.any())), version: schema.maybe(schema.number()), + onFailure: schema.maybe(schema.arrayOf(schema.recordOf(schema.string(), schema.any()))), }); export const registerCreateRoute = ({ @@ -33,7 +34,7 @@ export const registerCreateRoute = ({ const { callAsCurrentUser } = ctx.core.elasticsearch.dataClient; const pipeline = req.body as Pipeline; - const { name, description, processors, version } = pipeline; + const { name, description, processors, version, onFailure } = pipeline; try { // Check that a pipeline with the same name doesn't already exist @@ -62,6 +63,7 @@ export const registerCreateRoute = ({ description, processors, version, + on_failure: onFailure, }, }); diff --git a/x-pack/plugins/ingest_pipelines/server/routes/api/update.ts b/x-pack/plugins/ingest_pipelines/server/routes/api/update.ts index fa5ee440285f1..c130342475b49 100644 --- a/x-pack/plugins/ingest_pipelines/server/routes/api/update.ts +++ b/x-pack/plugins/ingest_pipelines/server/routes/api/update.ts @@ -11,8 +11,9 @@ import { RouteDependencies } from '../../types'; const bodySchema = schema.object({ description: schema.string(), - processors: schema.arrayOf(schema.any()), // todo fix + processors: schema.arrayOf(schema.recordOf(schema.string(), schema.any())), version: schema.maybe(schema.number()), + onFailure: schema.maybe(schema.arrayOf(schema.recordOf(schema.string(), schema.any()))), }); const paramsSchema = schema.object({ @@ -37,7 +38,7 @@ export const registerUpdateRoute = ({ const { name } = req.params as typeof paramsSchema.type; const pipeline = req.body as Pipeline; - const { description, processors, version } = pipeline; + const { description, processors, version, onFailure } = pipeline; try { // Verify pipeline exists; ES will throw 404 if it doesn't @@ -49,6 +50,7 @@ export const registerUpdateRoute = ({ description, processors, version, + on_failure: onFailure, }, }); diff --git a/x-pack/test/api_integration/apis/management/ingest_pipelines/ingest_pipelines.ts b/x-pack/test/api_integration/apis/management/ingest_pipelines/ingest_pipelines.ts index 2ec58949c491b..2b2a64302d839 100644 --- a/x-pack/test/api_integration/apis/management/ingest_pipelines/ingest_pipelines.ts +++ b/x-pack/test/api_integration/apis/management/ingest_pipelines/ingest_pipelines.ts @@ -35,6 +35,14 @@ export default function({ getService }: FtrProviderContext) { }, }, ], + onFailure: [ + { + set: { + field: 'error.message', + value: '{{ failure_message }}', + }, + }, + ], version: 1, }) .expect(200); From d6f862c30602bb97807acdeabc6ddd472a5227d4 Mon Sep 17 00:00:00 2001 From: Alison Goryachev Date: Wed, 8 Apr 2020 12:44:31 -0400 Subject: [PATCH 5/5] address review feedback --- .../ingest_pipelines/common/lib/pipeline_serialization.ts | 8 +------- .../plugins/ingest_pipelines/server/routes/api/update.ts | 2 +- .../plugins/ingest_pipelines/server/services/license.ts | 4 ++-- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/x-pack/plugins/ingest_pipelines/common/lib/pipeline_serialization.ts b/x-pack/plugins/ingest_pipelines/common/lib/pipeline_serialization.ts index 11061d096c224..9fd41c5695881 100644 --- a/x-pack/plugins/ingest_pipelines/common/lib/pipeline_serialization.ts +++ b/x-pack/plugins/ingest_pipelines/common/lib/pipeline_serialization.ts @@ -20,13 +20,7 @@ export function deserializePipelines(pipelinesByName: PipelinesByName): Pipeline onFailure: on_failure, }; - // Remove any undefined values - return Object.entries(pipeline).reduce((pipelineDefinition: any, [key, value]) => { - if (value !== undefined) { - pipelineDefinition[key] = value; - } - return pipelineDefinition; - }, {}); + return pipeline; }); return deserializedPipelines; diff --git a/x-pack/plugins/ingest_pipelines/server/routes/api/update.ts b/x-pack/plugins/ingest_pipelines/server/routes/api/update.ts index c130342475b49..4a13c3b15b754 100644 --- a/x-pack/plugins/ingest_pipelines/server/routes/api/update.ts +++ b/x-pack/plugins/ingest_pipelines/server/routes/api/update.ts @@ -35,7 +35,7 @@ export const registerUpdateRoute = ({ }, license.guardApiRoute(async (ctx, req, res) => { const { callAsCurrentUser } = ctx.core.elasticsearch.dataClient; - const { name } = req.params as typeof paramsSchema.type; + const { name } = req.params; const pipeline = req.body as Pipeline; const { description, processors, version, onFailure } = pipeline; diff --git a/x-pack/plugins/ingest_pipelines/server/services/license.ts b/x-pack/plugins/ingest_pipelines/server/services/license.ts index 31d3654c51e3e..0a4748bd0ace0 100644 --- a/x-pack/plugins/ingest_pipelines/server/services/license.ts +++ b/x-pack/plugins/ingest_pipelines/server/services/license.ts @@ -53,12 +53,12 @@ export class License { }); } - guardApiRoute(handler: RequestHandler) { + guardApiRoute(handler: RequestHandler) { const license = this; return function licenseCheck( ctx: RequestHandlerContext, - request: KibanaRequest, + request: KibanaRequest, response: KibanaResponseFactory ) { const licenseStatus = license.getStatus();