From 44ee51c59ff97a6bf5772a742c03ccea17bcd9d0 Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Mon, 4 Mar 2019 11:03:07 +0300 Subject: [PATCH] Logstash central management typeless API (#30546) (#32282) This commit adopts Elasticsearch's typeless API for Logstash central management. Relates: https://github.com/elastic/elasticsearch/issues/3863 --- x-pack/plugins/logstash/common/constants/index.js | 1 - .../plugins/logstash/common/constants/type_names.js | 11 ----------- .../routes/api/pipeline/register_delete_route.js | 3 +-- .../server/routes/api/pipeline/register_load_route.js | 3 +-- .../server/routes/api/pipeline/register_save_route.js | 3 +-- .../routes/api/pipelines/register_delete_route.js | 3 +-- .../routes/api/upgrade/register_execute_route.js | 4 +--- 7 files changed, 5 insertions(+), 23 deletions(-) delete mode 100755 x-pack/plugins/logstash/common/constants/type_names.js diff --git a/x-pack/plugins/logstash/common/constants/index.js b/x-pack/plugins/logstash/common/constants/index.js index 03a6b4e08d9f..aebd3294ac35 100755 --- a/x-pack/plugins/logstash/common/constants/index.js +++ b/x-pack/plugins/logstash/common/constants/index.js @@ -5,7 +5,6 @@ */ export { INDEX_NAMES } from './index_names'; -export { TYPE_NAMES } from './type_names'; export { ROUTES } from './routes'; export { PAGINATION } from './pagination'; export { PLUGIN } from './plugin'; diff --git a/x-pack/plugins/logstash/common/constants/type_names.js b/x-pack/plugins/logstash/common/constants/type_names.js deleted file mode 100755 index 959f39fd311f..000000000000 --- a/x-pack/plugins/logstash/common/constants/type_names.js +++ /dev/null @@ -1,11 +0,0 @@ -/* - * 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 const TYPE_NAMES = { - // ES is removing types for 6.0.0, so we'll need to use `doc` until - // they support PUT {index}/_doc/{id} - PIPELINES: 'doc', -}; diff --git a/x-pack/plugins/logstash/server/routes/api/pipeline/register_delete_route.js b/x-pack/plugins/logstash/server/routes/api/pipeline/register_delete_route.js index 9702e35ac515..9384f302f7a4 100755 --- a/x-pack/plugins/logstash/server/routes/api/pipeline/register_delete_route.js +++ b/x-pack/plugins/logstash/server/routes/api/pipeline/register_delete_route.js @@ -6,13 +6,12 @@ import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { wrapEsError } from '../../../lib/error_wrappers'; -import { INDEX_NAMES, TYPE_NAMES } from '../../../../common/constants'; +import { INDEX_NAMES } from '../../../../common/constants'; import { licensePreRoutingFactory } from'../../../lib/license_pre_routing_factory'; function deletePipeline(callWithRequest, pipelineId) { return callWithRequest('delete', { index: INDEX_NAMES.PIPELINES, - type: TYPE_NAMES.PIPELINES, id: pipelineId, refresh: 'wait_for' }); diff --git a/x-pack/plugins/logstash/server/routes/api/pipeline/register_load_route.js b/x-pack/plugins/logstash/server/routes/api/pipeline/register_load_route.js index 90e897a18eb8..ef63cf4cb2d7 100755 --- a/x-pack/plugins/logstash/server/routes/api/pipeline/register_load_route.js +++ b/x-pack/plugins/logstash/server/routes/api/pipeline/register_load_route.js @@ -5,7 +5,7 @@ */ import Boom from 'boom'; -import { INDEX_NAMES, TYPE_NAMES } from '../../../../common/constants'; +import { INDEX_NAMES } from '../../../../common/constants'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { Pipeline } from '../../../models/pipeline'; import { licensePreRoutingFactory } from'../../../lib/license_pre_routing_factory'; @@ -13,7 +13,6 @@ import { licensePreRoutingFactory } from'../../../lib/license_pre_routing_factor function fetchPipeline(callWithRequest, pipelineId) { return callWithRequest('get', { index: INDEX_NAMES.PIPELINES, - type: TYPE_NAMES.PIPELINES, id: pipelineId, _source: [ 'description', diff --git a/x-pack/plugins/logstash/server/routes/api/pipeline/register_save_route.js b/x-pack/plugins/logstash/server/routes/api/pipeline/register_save_route.js index 235392e42620..102b1b6da05b 100755 --- a/x-pack/plugins/logstash/server/routes/api/pipeline/register_save_route.js +++ b/x-pack/plugins/logstash/server/routes/api/pipeline/register_save_route.js @@ -6,7 +6,7 @@ import { get } from 'lodash'; import { wrapEsError } from '../../../lib/error_wrappers'; -import { INDEX_NAMES, TYPE_NAMES } from '../../../../common/constants'; +import { INDEX_NAMES } from '../../../../common/constants'; import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { Pipeline } from '../../../models/pipeline'; import { licensePreRoutingFactory } from'../../../lib/license_pre_routing_factory'; @@ -14,7 +14,6 @@ import { licensePreRoutingFactory } from'../../../lib/license_pre_routing_factor function savePipeline(callWithRequest, pipelineId, pipelineBody) { return callWithRequest('index', { index: INDEX_NAMES.PIPELINES, - type: TYPE_NAMES.PIPELINES, id: pipelineId, body: pipelineBody, refresh: 'wait_for' diff --git a/x-pack/plugins/logstash/server/routes/api/pipelines/register_delete_route.js b/x-pack/plugins/logstash/server/routes/api/pipelines/register_delete_route.js index faed6d2149eb..1ddbf227ffb3 100755 --- a/x-pack/plugins/logstash/server/routes/api/pipelines/register_delete_route.js +++ b/x-pack/plugins/logstash/server/routes/api/pipelines/register_delete_route.js @@ -6,14 +6,13 @@ import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { wrapUnknownError } from '../../../lib/error_wrappers'; -import { INDEX_NAMES, TYPE_NAMES } from '../../../../common/constants'; +import { INDEX_NAMES } from '../../../../common/constants'; import { licensePreRoutingFactory } from'../../../lib/license_pre_routing_factory'; function deletePipelines(callWithRequest, pipelineIds) { const deletePromises = pipelineIds.map(pipelineId => { return callWithRequest('delete', { index: INDEX_NAMES.PIPELINES, - type: TYPE_NAMES.PIPELINES, id: pipelineId, refresh: 'wait_for' }) diff --git a/x-pack/plugins/logstash/server/routes/api/upgrade/register_execute_route.js b/x-pack/plugins/logstash/server/routes/api/upgrade/register_execute_route.js index aa0517e089b5..c86adc612076 100755 --- a/x-pack/plugins/logstash/server/routes/api/upgrade/register_execute_route.js +++ b/x-pack/plugins/logstash/server/routes/api/upgrade/register_execute_route.js @@ -6,7 +6,7 @@ import { callWithRequestFactory } from '../../../lib/call_with_request_factory'; import { wrapUnknownError } from '../../../lib/error_wrappers'; -import { INDEX_NAMES, TYPE_NAMES } from '../../../../common/constants'; +import { INDEX_NAMES } from '../../../../common/constants'; import { licensePreRoutingFactory } from'../../../lib/license_pre_routing_factory'; function doesIndexExist(callWithRequest) { @@ -24,8 +24,6 @@ async function executeUpgrade(callWithRequest) { return callWithRequest('indices.putMapping', { index: INDEX_NAMES.PIPELINES, - include_type_name: true, - type: TYPE_NAMES.PIPELINES, body: { properties: { pipeline_settings: {