diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index e707250ff3261..267f3dde0b66f 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -180,7 +180,7 @@
/src/plugins/console/ @elastic/es-ui
/src/plugins/es_ui_shared/ @elastic/es-ui
/x-pack/legacy/plugins/cross_cluster_replication/ @elastic/es-ui
-/x-pack/legacy/plugins/index_lifecycle_management/ @elastic/es-ui
+/x-pack/plugins/index_lifecycle_management/ @elastic/es-ui
/x-pack/legacy/plugins/index_management/ @elastic/es-ui
/x-pack/legacy/plugins/license_management/ @elastic/es-ui
/x-pack/legacy/plugins/rollup/ @elastic/es-ui
diff --git a/x-pack/.i18nrc.json b/x-pack/.i18nrc.json
index ae8d61769b14c..bbbcc062786b0 100644
--- a/x-pack/.i18nrc.json
+++ b/x-pack/.i18nrc.json
@@ -18,7 +18,7 @@
"xpack.graph": ["legacy/plugins/graph", "plugins/graph"],
"xpack.grokDebugger": "plugins/grokdebugger",
"xpack.idxMgmt": "plugins/index_management",
- "xpack.indexLifecycleMgmt": "legacy/plugins/index_lifecycle_management",
+ "xpack.indexLifecycleMgmt": "plugins/index_lifecycle_management",
"xpack.infra": "plugins/infra",
"xpack.ingestManager": "plugins/ingest_manager",
"xpack.lens": "legacy/plugins/lens",
diff --git a/x-pack/index.js b/x-pack/index.js
index 6fab13d726fa6..3126dc17a7107 100644
--- a/x-pack/index.js
+++ b/x-pack/index.js
@@ -16,7 +16,6 @@ import { beats } from './legacy/plugins/beats_management';
import { apm } from './legacy/plugins/apm';
import { maps } from './legacy/plugins/maps';
import { indexManagement } from './legacy/plugins/index_management';
-import { indexLifecycleManagement } from './legacy/plugins/index_lifecycle_management';
import { spaces } from './legacy/plugins/spaces';
import { canvas } from './legacy/plugins/canvas';
import { infra } from './legacy/plugins/infra';
@@ -50,7 +49,6 @@ module.exports = function(kibana) {
maps(kibana),
canvas(kibana),
indexManagement(kibana),
- indexLifecycleManagement(kibana),
infra(kibana),
taskManager(kibana),
rollup(kibana),
diff --git a/x-pack/legacy/plugins/cross_cluster_replication/public/np_ready/extend_index_management.ts b/x-pack/legacy/plugins/cross_cluster_replication/public/np_ready/extend_index_management.ts
index 01c6250383fb8..4ffe0db4e3c4e 100644
--- a/x-pack/legacy/plugins/cross_cluster_replication/public/np_ready/extend_index_management.ts
+++ b/x-pack/legacy/plugins/cross_cluster_replication/public/np_ready/extend_index_management.ts
@@ -6,7 +6,7 @@
import { i18n } from '@kbn/i18n';
import { get } from 'lodash';
-import { IndexMgmtSetup } from '../../../../../plugins/index_management/public';
+import { IndexManagementPluginSetup } from '../../../../../plugins/index_management/public';
const propertyPath = 'isFollowerIndex';
@@ -21,7 +21,7 @@ const followerBadgeExtension = {
filterExpression: 'isFollowerIndex:true',
};
-export const extendIndexManagement = (indexManagement?: IndexMgmtSetup) => {
+export const extendIndexManagement = (indexManagement?: IndexManagementPluginSetup) => {
if (indexManagement) {
indexManagement.extensionsService.addBadge(followerBadgeExtension);
}
diff --git a/x-pack/legacy/plugins/cross_cluster_replication/public/np_ready/plugin.ts b/x-pack/legacy/plugins/cross_cluster_replication/public/np_ready/plugin.ts
index f7651cbb210a7..46259c698b282 100644
--- a/x-pack/legacy/plugins/cross_cluster_replication/public/np_ready/plugin.ts
+++ b/x-pack/legacy/plugins/cross_cluster_replication/public/np_ready/plugin.ts
@@ -11,7 +11,7 @@ import {
DocLinksStart,
} from 'src/core/public';
-import { IndexMgmtSetup } from '../../../../../plugins/index_management/public';
+import { IndexManagementPluginSetup } from '../../../../../plugins/index_management/public';
// @ts-ignore;
import { setHttpClient } from './app/services/api';
@@ -21,7 +21,7 @@ import { setNotifications } from './app/services/notifications';
import { extendIndexManagement } from './extend_index_management';
interface PluginDependencies {
- indexManagement: IndexMgmtSetup;
+ indexManagement: IndexManagementPluginSetup;
__LEGACY: {
chrome: any;
MANAGEMENT_BREADCRUMB: ChromeBreadcrumb;
diff --git a/x-pack/legacy/plugins/cross_cluster_replication/server/np_ready/plugin.ts b/x-pack/legacy/plugins/cross_cluster_replication/server/np_ready/plugin.ts
index 1012c07af3d2a..829de10ad0177 100644
--- a/x-pack/legacy/plugins/cross_cluster_replication/server/np_ready/plugin.ts
+++ b/x-pack/legacy/plugins/cross_cluster_replication/server/np_ready/plugin.ts
@@ -6,7 +6,7 @@
import { Plugin, PluginInitializerContext, CoreSetup } from 'src/core/server';
-import { IndexMgmtSetup } from '../../../../../plugins/index_management/server';
+import { IndexManagementPluginSetup } from '../../../../../plugins/index_management/server';
// @ts-ignore
import { registerLicenseChecker } from './lib/register_license_checker';
@@ -15,7 +15,7 @@ import { registerRoutes } from './routes/register_routes';
import { ccrDataEnricher } from './cross_cluster_replication_data';
interface PluginDependencies {
- indexManagement: IndexMgmtSetup;
+ indexManagement: IndexManagementPluginSetup;
__LEGACY: {
server: any;
ccrUIEnabled: boolean;
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/index.ts b/x-pack/legacy/plugins/index_lifecycle_management/index.ts
deleted file mode 100644
index 9b14b7143bf44..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/index.ts
+++ /dev/null
@@ -1,62 +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.
- */
-
-import { Legacy } from 'kibana';
-import { resolve } from 'path';
-import { PLUGIN } from './common/constants';
-import { Plugin as IndexLifecycleManagementPlugin } from './plugin';
-import { createShim } from './shim';
-
-export function indexLifecycleManagement(kibana: any) {
- return new kibana.Plugin({
- id: PLUGIN.ID,
- configPrefix: 'xpack.ilm',
- publicDir: resolve(__dirname, 'public'),
- require: ['kibana', 'elasticsearch', 'xpack_main', 'index_management'],
- uiExports: {
- styleSheetPaths: resolve(__dirname, 'public/np_ready/application/index.scss'),
- managementSections: ['plugins/index_lifecycle_management/legacy'],
- injectDefaultVars(server: Legacy.Server) {
- const config = server.config();
- return {
- ilmUiEnabled: config.get('xpack.ilm.ui.enabled'),
- };
- },
- },
- config: (Joi: any) => {
- return Joi.object({
- // display menu item
- ui: Joi.object({
- enabled: Joi.boolean().default(true),
- }).default(),
-
- // enable plugin
- enabled: Joi.boolean().default(true),
-
- filteredNodeAttributes: Joi.array()
- .items(Joi.string())
- .default([]),
- }).default();
- },
- isEnabled(config: any) {
- return (
- config.get('xpack.ilm.enabled') &&
- config.has('xpack.index_management.enabled') &&
- config.get('xpack.index_management.enabled')
- );
- },
- init(server: Legacy.Server) {
- const core = server.newPlatform.setup.core;
- const plugins = {};
- const __LEGACY = createShim(server);
-
- const indexLifecycleManagementPlugin = new IndexLifecycleManagementPlugin();
-
- // Set up plugin.
- indexLifecycleManagementPlugin.setup(core, plugins, __LEGACY);
- },
- });
-}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/plugin.ts b/x-pack/legacy/plugins/index_lifecycle_management/plugin.ts
deleted file mode 100644
index 38d1bea45ce07..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/plugin.ts
+++ /dev/null
@@ -1,54 +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.
- */
-
-import { CoreSetup } from 'kibana/server';
-import { LegacySetup } from './shim';
-import { registerLicenseChecker } from './server/lib/register_license_checker';
-import { registerIndexRoutes } from './server/routes/api/index';
-import { registerNodesRoutes } from './server/routes/api/nodes';
-import { registerPoliciesRoutes } from './server/routes/api/policies';
-import { registerTemplatesRoutes } from './server/routes/api/templates';
-
-const indexLifecycleDataEnricher = async (indicesList: any, callWithRequest: any) => {
- if (!indicesList || !indicesList.length) {
- return;
- }
- const params = {
- path: '/*/_ilm/explain',
- method: 'GET',
- };
- const { indices: ilmIndicesData } = await callWithRequest('transport.request', params);
- return indicesList.map((index: any): any => {
- return {
- ...index,
- ilm: { ...(ilmIndicesData[index.name] || {}) },
- };
- });
-};
-
-export class Plugin {
- public setup(core: CoreSetup, plugins: any, __LEGACY: LegacySetup): void {
- const { server } = __LEGACY;
-
- registerLicenseChecker(server);
-
- // Register routes.
- registerIndexRoutes(server);
- registerNodesRoutes(server);
- registerPoliciesRoutes(server);
- registerTemplatesRoutes(server);
-
- const serverPlugins = server.newPlatform.setup.plugins as any;
-
- if (
- server.config().get('xpack.ilm.ui.enabled') &&
- serverPlugins.indexManagement &&
- serverPlugins.indexManagement.indexDataEnricher
- ) {
- serverPlugins.indexManagement.indexDataEnricher.add(indexLifecycleDataEnricher);
- }
- }
-}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/legacy.ts b/x-pack/legacy/plugins/index_lifecycle_management/public/legacy.ts
deleted file mode 100644
index 006e5f6098f2b..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/public/legacy.ts
+++ /dev/null
@@ -1,109 +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.
- */
-
-import { App } from 'src/core/public';
-
-/* Legacy Imports */
-import { npSetup, npStart } from 'ui/new_platform';
-import chrome from 'ui/chrome';
-import routes from 'ui/routes';
-import { management } from 'ui/management';
-import { createUiStatsReporter } from '../../../../../src/legacy/core_plugins/ui_metric/public';
-
-import { PLUGIN, BASE_PATH } from '../common/constants';
-import { createPlugin } from './np_ready';
-import { addAllExtensions } from './np_ready/extend_index_management';
-
-if (chrome.getInjected('ilmUiEnabled')) {
- // We have to initialize this outside of the NP lifecycle, otherwise these extensions won't
- // be available in Index Management unless the user visits ILM first.
- if ((npSetup.plugins as any).indexManagement) {
- addAllExtensions((npSetup.plugins as any).indexManagement.extensionsService);
- }
-
- // This method handles the cleanup needed when route is scope is destroyed. It also prevents Angular
- // from destroying scope when route changes and both old route and new route are this same route.
- const manageAngularLifecycle = ($scope: any, $route: any, unmount: () => void) => {
- const lastRoute = $route.current;
- const deregister = $scope.$on('$locationChangeSuccess', () => {
- const currentRoute = $route.current;
- // if templates are the same we are on the same route
- if (lastRoute.$$route.template === currentRoute.$$route.template) {
- // this prevents angular from destroying scope
- $route.current = lastRoute;
- }
- });
- $scope.$on('$destroy', () => {
- if (deregister) {
- deregister();
- }
- unmount();
- });
- };
-
- // Once this app no longer depends upon Angular's routing (e.g. for the "redirect" service), we can
- // use the Management plugin's API to register this app within the Elasticsearch section.
- const esSection = management.getSection('elasticsearch');
- esSection.register('index_lifecycle_policies', {
- visible: true,
- display: PLUGIN.TITLE,
- order: 2,
- url: `#${BASE_PATH}policies`,
- });
-
- const REACT_ROOT_ID = 'indexLifecycleManagementReactRoot';
-
- const template = `
-
-
- `;
-
- routes.when(`${BASE_PATH}:view?/:action?/:id?`, {
- template,
- controllerAs: 'indexLifecycleManagement',
- controller: class IndexLifecycleManagementController {
- constructor($scope: any, $route: any, kbnUrl: any, $rootScope: any) {
- $scope.$$postDigest(() => {
- const element = document.getElementById(REACT_ROOT_ID)!;
- const { core } = npSetup;
-
- const coreDependencies = {
- ...core,
- application: {
- ...core.application,
- async register(app: App) {
- const unmountApp = await app.mount({ ...npStart } as any, {
- element,
- appBasePath: '',
- onAppLeave: () => undefined,
- // TODO: adapt to use Core's ScopedHistory
- history: {} as any,
- });
- manageAngularLifecycle($scope, $route, unmountApp as any);
- },
- },
- };
-
- // The Plugin interface won't allow us to pass __LEGACY as a third argument, so we'll just
- // sneak it inside of the plugins argument for now.
- const pluginDependencies = {
- __LEGACY: {
- redirect: (path: string) => {
- $scope.$evalAsync(() => {
- kbnUrl.redirect(path);
- });
- },
- createUiStatsReporter,
- },
- };
-
- const plugin = createPlugin({} as any);
- plugin.setup(coreDependencies, pluginDependencies);
- });
- }
- } as any,
- } as any);
-}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/_index_lifecycle_management.scss b/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/_index_lifecycle_management.scss
deleted file mode 100644
index 96c6d1a938c61..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/_index_lifecycle_management.scss
+++ /dev/null
@@ -1,17 +0,0 @@
-.policyTable__horizontalScrollContainer {
- overflow-x: auto;
- max-width: 100%;
-}
-
-.policyTable__horizontalScroll {
- min-width: 800px;
- width: 100%;
-}
-
-.policyTable__link {
- font-weight: 400;
-}
-
-.ilmEditPolicyPageContent {
- max-width: 1200px !important;
-}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/index.scss b/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/index.scss
deleted file mode 100644
index 53e90e2aae35b..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/index.scss
+++ /dev/null
@@ -1,3 +0,0 @@
-// Import the EUI global scope so we can use EUI constants
-@import 'src/legacy/ui/public/styles/_styling_constants';
-@import 'index_lifecycle_management';
\ No newline at end of file
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/index.tsx b/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/index.tsx
deleted file mode 100644
index b87a633d65c9c..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/index.tsx
+++ /dev/null
@@ -1,63 +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.
- */
-
-import React from 'react';
-import { render, unmountComponentAtNode } from 'react-dom';
-import { Provider } from 'react-redux';
-import { DocLinksStart, ToastsSetup, HttpSetup, FatalErrorsSetup } from 'src/core/public';
-
-import { App } from './app';
-import { indexLifecycleManagementStore } from './store';
-import { init as initHttp } from './services/http';
-import { init as initNavigation } from './services/navigation';
-import { init as initDocumentation } from './services/documentation';
-import { init as initUiMetric } from './services/ui_metric';
-import { init as initNotification } from './services/notification';
-
-export interface LegacySetup {
- redirect: any;
- createUiStatsReporter: any;
-}
-
-interface AppDependencies {
- legacy: LegacySetup;
- I18nContext: any;
- http: HttpSetup;
- toasts: ToastsSetup;
- fatalErrors: FatalErrorsSetup;
- docLinks: DocLinksStart;
- element: HTMLElement;
-}
-
-export const renderApp = (appDependencies: AppDependencies) => {
- const {
- legacy: { redirect, createUiStatsReporter },
- I18nContext,
- http,
- toasts,
- fatalErrors,
- docLinks: { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION },
- element,
- } = appDependencies;
-
- // Initialize services
- initHttp(http);
- initNavigation(redirect);
- initDocumentation(`${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference/${DOC_LINK_VERSION}/`);
- initUiMetric(createUiStatsReporter);
- initNotification(toasts, fatalErrors);
-
- render(
-
-
-
-
- ,
- element
- );
-
- return () => unmountComponentAtNode(element);
-};
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/api.js b/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/api.js
deleted file mode 100644
index f13bbcb6162b8..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/api.js
+++ /dev/null
@@ -1,81 +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.
- */
-
-import {
- UIM_POLICY_DELETE,
- UIM_POLICY_ATTACH_INDEX,
- UIM_POLICY_ATTACH_INDEX_TEMPLATE,
- UIM_POLICY_DETACH_INDEX,
- UIM_INDEX_RETRY_STEP,
-} from '../constants';
-
-import { trackUiMetric } from './ui_metric';
-import { sendGet, sendPost, sendDelete } from './http';
-
-// The extend_index_management module that we support an injected httpClient here.
-
-export async function loadNodes(httpClient) {
- return await sendGet(`nodes/list`, httpClient);
-}
-
-export async function loadNodeDetails(selectedNodeAttrs, httpClient) {
- return await sendGet(`nodes/${selectedNodeAttrs}/details`, httpClient);
-}
-
-export async function loadIndexTemplates(httpClient) {
- return await sendGet(`templates`, httpClient);
-}
-
-export async function loadIndexTemplate(templateName, httpClient) {
- if (!templateName) {
- return {};
- }
- return await sendGet(`templates/${templateName}`, httpClient);
-}
-
-export async function loadPolicies(withIndices, httpClient) {
- const query = withIndices ? '?withIndices=true' : '';
- return await sendGet('policies', query, httpClient);
-}
-
-export async function savePolicy(policy, httpClient) {
- return await sendPost(`policies`, policy, httpClient);
-}
-
-export async function deletePolicy(policyName, httpClient) {
- const response = await sendDelete(`policies/${encodeURIComponent(policyName)}`, httpClient);
- // Only track successful actions.
- trackUiMetric('count', UIM_POLICY_DELETE);
- return response;
-}
-
-export const retryLifecycleForIndex = async (indexNames, httpClient) => {
- const response = await sendPost(`index/retry`, { indexNames }, httpClient);
- // Only track successful actions.
- trackUiMetric('count', UIM_INDEX_RETRY_STEP);
- return response;
-};
-
-export const removeLifecycleForIndex = async (indexNames, httpClient) => {
- const response = await sendPost(`index/remove`, { indexNames }, httpClient);
- // Only track successful actions.
- trackUiMetric('count', UIM_POLICY_DETACH_INDEX);
- return response;
-};
-
-export const addLifecyclePolicyToIndex = async (body, httpClient) => {
- const response = await sendPost(`index/add`, body, httpClient);
- // Only track successful actions.
- trackUiMetric('count', UIM_POLICY_ATTACH_INDEX);
- return response;
-};
-
-export const addLifecyclePolicyToTemplate = async (body, httpClient) => {
- const response = await sendPost(`template`, body, httpClient);
- // Only track successful actions.
- trackUiMetric('count', UIM_POLICY_ATTACH_INDEX_TEMPLATE);
- return response;
-};
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/plugin.tsx b/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/plugin.tsx
deleted file mode 100644
index e2897f09fa892..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/plugin.tsx
+++ /dev/null
@@ -1,58 +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.
- */
-
-import { CoreSetup, CoreStart, Plugin } from 'src/core/public';
-import { PLUGIN } from '../../common/constants';
-import { LegacySetup } from './application';
-
-interface PluginsSetup {
- __LEGACY: LegacySetup;
-}
-
-export class IndexLifecycleManagementPlugin implements Plugin {
- setup(core: CoreSetup, plugins: PluginsSetup) {
- // Extract individual core dependencies.
- const {
- application,
- notifications: { toasts },
- fatalErrors,
- http,
- } = core;
-
- // The Plugin interface won't allow us to pass __LEGACY as a third argument, so we'll just
- // sneak it inside of the plugins parameter for now.
- const { __LEGACY } = plugins;
-
- application.register({
- id: PLUGIN.ID,
- title: PLUGIN.TITLE,
- async mount(config, mountPoint) {
- const {
- core: {
- docLinks,
- i18n: { Context: I18nContext },
- },
- } = config;
-
- const { element } = mountPoint;
- const { renderApp } = await import('./application');
-
- // Inject all dependencies into our app.
- return renderApp({
- legacy: { ...__LEGACY },
- I18nContext,
- http,
- toasts,
- fatalErrors,
- docLinks,
- element,
- });
- },
- });
- }
- start(core: CoreStart, plugins: any) {}
- stop() {}
-}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/call_with_request_factory/call_with_request_factory.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/lib/call_with_request_factory/call_with_request_factory.ts
deleted file mode 100644
index 1b28dc4fde4f7..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/call_with_request_factory/call_with_request_factory.ts
+++ /dev/null
@@ -1,19 +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.
- */
-
-import { once } from 'lodash';
-import { Legacy } from 'kibana';
-
-const callWithRequest = once((server: Legacy.Server): any => {
- const cluster = server.plugins.elasticsearch.getCluster('data');
- return cluster.callWithRequest;
-});
-
-export const callWithRequestFactory = (server: Legacy.Server, request: any) => {
- return (...args: any[]) => {
- return callWithRequest(server)(request, ...args);
- };
-};
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/call_with_request_factory/index.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/lib/call_with_request_factory/index.ts
deleted file mode 100644
index 787814d87dff9..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/call_with_request_factory/index.ts
+++ /dev/null
@@ -1,7 +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 { callWithRequestFactory } from './call_with_request_factory';
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/check_license/__tests__/check_license.js b/x-pack/legacy/plugins/index_lifecycle_management/server/lib/check_license/__tests__/check_license.js
deleted file mode 100644
index 933fda01c055d..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/check_license/__tests__/check_license.js
+++ /dev/null
@@ -1,145 +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.
- */
-
-import expect from '@kbn/expect';
-import { set } from 'lodash';
-import { checkLicense } from '../check_license';
-
-describe('check_license', function() {
- let mockLicenseInfo;
- beforeEach(() => (mockLicenseInfo = {}));
-
- describe('license information is undefined', () => {
- beforeEach(() => (mockLicenseInfo = undefined));
-
- it('should set isAvailable to false', () => {
- expect(checkLicense(mockLicenseInfo).isAvailable).to.be(false);
- });
-
- it('should set showLinks to true', () => {
- expect(checkLicense(mockLicenseInfo).showLinks).to.be(true);
- });
-
- it('should set enableLinks to false', () => {
- expect(checkLicense(mockLicenseInfo).enableLinks).to.be(false);
- });
-
- it('should set a message', () => {
- expect(checkLicense(mockLicenseInfo).message).to.not.be(undefined);
- });
- });
-
- describe('license information is not available', () => {
- beforeEach(() => (mockLicenseInfo.isAvailable = () => false));
-
- it('should set isAvailable to false', () => {
- expect(checkLicense(mockLicenseInfo).isAvailable).to.be(false);
- });
-
- it('should set showLinks to true', () => {
- expect(checkLicense(mockLicenseInfo).showLinks).to.be(true);
- });
-
- it('should set enableLinks to false', () => {
- expect(checkLicense(mockLicenseInfo).enableLinks).to.be(false);
- });
-
- it('should set a message', () => {
- expect(checkLicense(mockLicenseInfo).message).to.not.be(undefined);
- });
- });
-
- describe('license information is available', () => {
- beforeEach(() => {
- mockLicenseInfo.isAvailable = () => true;
- set(mockLicenseInfo, 'license.getType', () => 'basic');
- });
-
- describe('& license is > basic', () => {
- beforeEach(() => set(mockLicenseInfo, 'license.isOneOf', () => true));
-
- describe('& license is active', () => {
- beforeEach(() => set(mockLicenseInfo, 'license.isActive', () => true));
-
- it('should set isAvailable to true', () => {
- expect(checkLicense(mockLicenseInfo).isAvailable).to.be(true);
- });
-
- it('should set showLinks to true', () => {
- expect(checkLicense(mockLicenseInfo).showLinks).to.be(true);
- });
-
- it('should set enableLinks to true', () => {
- expect(checkLicense(mockLicenseInfo).enableLinks).to.be(true);
- });
-
- it('should not set a message', () => {
- expect(checkLicense(mockLicenseInfo).message).to.be(undefined);
- });
- });
-
- describe('& license is expired', () => {
- beforeEach(() => set(mockLicenseInfo, 'license.isActive', () => false));
-
- it('should set isAvailable to false', () => {
- expect(checkLicense(mockLicenseInfo).isAvailable).to.be(false);
- });
-
- it('should set showLinks to true', () => {
- expect(checkLicense(mockLicenseInfo).showLinks).to.be(true);
- });
-
- it('should set enableLinks to false', () => {
- expect(checkLicense(mockLicenseInfo).enableLinks).to.be(false);
- });
-
- it('should set a message', () => {
- expect(checkLicense(mockLicenseInfo).message).to.not.be(undefined);
- });
- });
- });
-
- describe('& license is basic', () => {
- beforeEach(() => set(mockLicenseInfo, 'license.isOneOf', () => true));
-
- describe('& license is active', () => {
- beforeEach(() => set(mockLicenseInfo, 'license.isActive', () => true));
-
- it('should set isAvailable to true', () => {
- expect(checkLicense(mockLicenseInfo).isAvailable).to.be(true);
- });
-
- it('should set showLinks to true', () => {
- expect(checkLicense(mockLicenseInfo).showLinks).to.be(true);
- });
-
- it('should set enableLinks to true', () => {
- expect(checkLicense(mockLicenseInfo).enableLinks).to.be(true);
- });
-
- it('should not set a message', () => {
- expect(checkLicense(mockLicenseInfo).message).to.be(undefined);
- });
- });
-
- describe('& license is expired', () => {
- beforeEach(() => set(mockLicenseInfo, 'license.isActive', () => false));
-
- it('should set isAvailable to false', () => {
- expect(checkLicense(mockLicenseInfo).isAvailable).to.be(false);
- });
-
- it('should set showLinks to true', () => {
- expect(checkLicense(mockLicenseInfo).showLinks).to.be(true);
- });
-
- it('should set a message', () => {
- expect(checkLicense(mockLicenseInfo).message).to.not.be(undefined);
- });
- });
- });
- });
-});
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/check_license/check_license.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/lib/check_license/check_license.ts
deleted file mode 100644
index b35ab14964d55..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/check_license/check_license.ts
+++ /dev/null
@@ -1,66 +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.
- */
-
-import { i18n } from '@kbn/i18n';
-
-export function checkLicense(xpackLicenseInfo: any): any {
- const pluginName = 'Index Lifecycle Policies';
-
- // If, for some reason, we cannot get the license information
- // from Elasticsearch, assume worst case and disable
- if (!xpackLicenseInfo || !xpackLicenseInfo.isAvailable()) {
- return {
- isAvailable: false,
- showLinks: true,
- enableLinks: false,
- message: i18n.translate('xpack.indexLifecycleMgmt.checkLicense.errorUnavailableMessage', {
- defaultMessage:
- 'You cannot use {pluginName} because license information is not available at this time.',
- values: { pluginName },
- }),
- };
- }
-
- const VALID_LICENSE_MODES = ['basic', 'standard', 'gold', 'platinum', 'enterprise', 'trial'];
-
- const isLicenseModeValid = xpackLicenseInfo.license.isOneOf(VALID_LICENSE_MODES);
- const isLicenseActive = xpackLicenseInfo.license.isActive();
- const licenseType = xpackLicenseInfo.license.getType();
-
- // License is not valid
- if (!isLicenseModeValid) {
- return {
- isAvailable: false,
- showLinks: false,
- message: i18n.translate('xpack.indexLifecycleMgmt.checkLicense.errorUnsupportedMessage', {
- defaultMessage:
- 'Your {licenseType} license does not support {pluginName}. Please upgrade your license.',
- values: { licenseType, pluginName },
- }),
- };
- }
-
- // License is valid but not active
- if (!isLicenseActive) {
- return {
- isAvailable: false,
- showLinks: true,
- enableLinks: false,
- message: i18n.translate('xpack.indexLifecycleMgmt.checkLicense.errorExpiredMessage', {
- defaultMessage:
- 'You cannot use {pluginName} because your {licenseType} license has expired.',
- values: { pluginName, licenseType },
- }),
- };
- }
-
- // License is valid and active
- return {
- isAvailable: true,
- showLinks: true,
- enableLinks: true,
- };
-}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/error_wrappers/__tests__/wrap_custom_error.js b/x-pack/legacy/plugins/index_lifecycle_management/server/lib/error_wrappers/__tests__/wrap_custom_error.js
deleted file mode 100644
index f9c102be7a1ff..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/error_wrappers/__tests__/wrap_custom_error.js
+++ /dev/null
@@ -1,21 +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.
- */
-
-import expect from '@kbn/expect';
-import { wrapCustomError } from '../wrap_custom_error';
-
-describe('wrap_custom_error', () => {
- describe('#wrapCustomError', () => {
- it('should return a Boom object', () => {
- const originalError = new Error('I am an error');
- const statusCode = 404;
- const wrappedError = wrapCustomError(originalError, statusCode);
-
- expect(wrappedError.isBoom).to.be(true);
- expect(wrappedError.output.statusCode).to.equal(statusCode);
- });
- });
-});
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/error_wrappers/__tests__/wrap_es_error.js b/x-pack/legacy/plugins/index_lifecycle_management/server/lib/error_wrappers/__tests__/wrap_es_error.js
deleted file mode 100644
index fe2b6cce652f1..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/error_wrappers/__tests__/wrap_es_error.js
+++ /dev/null
@@ -1,38 +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.
- */
-
-import expect from '@kbn/expect';
-import { wrapEsError } from '../wrap_es_error';
-
-describe('wrap_es_error', () => {
- describe('#wrapEsError', () => {
- let originalError;
- beforeEach(() => {
- originalError = new Error('I am an error');
- originalError.statusCode = 404;
- });
-
- it('should return a Boom object', () => {
- const wrappedError = wrapEsError(originalError);
-
- expect(wrappedError.isBoom).to.be(true);
- });
-
- it('should return the correct Boom object', () => {
- const wrappedError = wrapEsError(originalError);
-
- expect(wrappedError.output.statusCode).to.be(originalError.statusCode);
- expect(wrappedError.output.payload.message).to.be(originalError.message);
- });
-
- it('should return the correct Boom object with custom message', () => {
- const wrappedError = wrapEsError(originalError, { 404: 'No encontrado!' });
-
- expect(wrappedError.output.statusCode).to.be(originalError.statusCode);
- expect(wrappedError.output.payload.message).to.be('No encontrado!');
- });
- });
-});
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/error_wrappers/__tests__/wrap_unknown_error.js b/x-pack/legacy/plugins/index_lifecycle_management/server/lib/error_wrappers/__tests__/wrap_unknown_error.js
deleted file mode 100644
index 85e0b2b3033ad..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/error_wrappers/__tests__/wrap_unknown_error.js
+++ /dev/null
@@ -1,19 +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.
- */
-
-import expect from '@kbn/expect';
-import { wrapUnknownError } from '../wrap_unknown_error';
-
-describe('wrap_unknown_error', () => {
- describe('#wrapUnknownError', () => {
- it('should return a Boom object', () => {
- const originalError = new Error('I am an error');
- const wrappedError = wrapUnknownError(originalError);
-
- expect(wrappedError.isBoom).to.be(true);
- });
- });
-});
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/error_wrappers/index.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/lib/error_wrappers/index.ts
deleted file mode 100644
index f275f15637091..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/error_wrappers/index.ts
+++ /dev/null
@@ -1,9 +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 { wrapCustomError } from './wrap_custom_error';
-export { wrapEsError } from './wrap_es_error';
-export { wrapUnknownError } from './wrap_unknown_error';
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/error_wrappers/wrap_custom_error.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/lib/error_wrappers/wrap_custom_error.ts
deleted file mode 100644
index c5780e7c83fb5..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/error_wrappers/wrap_custom_error.ts
+++ /dev/null
@@ -1,18 +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.
- */
-
-import Boom from 'boom';
-
-/**
- * Wraps a custom error into a Boom error response and returns it
- *
- * @param err Object error
- * @param statusCode Error status code
- * @return Object Boom error response
- */
-export function wrapCustomError(err: any, statusCode: any): any {
- return Boom.boomify(err, { statusCode });
-}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/error_wrappers/wrap_es_error.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/lib/error_wrappers/wrap_es_error.ts
deleted file mode 100644
index 6980a5afa5eac..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/error_wrappers/wrap_es_error.ts
+++ /dev/null
@@ -1,29 +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.
- */
-
-import Boom from 'boom';
-
-/**
- * Wraps an error thrown by the ES JS client into a Boom error response and returns it
- *
- * @param err Object Error thrown by ES JS client
- * @param statusCodeToMessageMap Object Optional map of HTTP status codes => error messages
- * @return Object Boom error response
- */
-export function wrapEsError(err: any, statusCodeToMessageMap: any = {}): any {
- const statusCode = err.statusCode;
-
- // If no custom message if specified for the error's status code, just
- // wrap the error as a Boom error response and return it
- if (!statusCodeToMessageMap[statusCode]) {
- return Boom.boomify(err, { statusCode });
- }
-
- // Otherwise, use the custom message to create a Boom error response and
- // return it
- const message = statusCodeToMessageMap[statusCode];
- return new Boom(message, { statusCode });
-}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/error_wrappers/wrap_unknown_error.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/lib/error_wrappers/wrap_unknown_error.ts
deleted file mode 100644
index ede1baec286f3..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/error_wrappers/wrap_unknown_error.ts
+++ /dev/null
@@ -1,17 +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.
- */
-
-import Boom from 'boom';
-
-/**
- * Wraps an unknown error into a Boom error response and returns it
- *
- * @param err Object Unknown error
- * @return Object Boom error response
- */
-export function wrapUnknownError(err: any): any {
- return Boom.boomify(err);
-}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/is_es_error/index.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/lib/is_es_error/index.ts
deleted file mode 100644
index a9a3c61472d8c..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/is_es_error/index.ts
+++ /dev/null
@@ -1,7 +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 { isEsError } from './is_es_error';
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js b/x-pack/legacy/plugins/index_lifecycle_management/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js
deleted file mode 100644
index 4d3b33f8b3af3..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.js
+++ /dev/null
@@ -1,69 +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.
- */
-
-import expect from '@kbn/expect';
-import { licensePreRoutingFactory } from '../license_pre_routing_factory';
-
-describe('license_pre_routing_factory', () => {
- describe('#reportingFeaturePreRoutingFactory', () => {
- let mockServer;
- let mockLicenseCheckResults;
-
- beforeEach(() => {
- mockServer = {
- plugins: {
- xpack_main: {
- info: {
- feature: () => ({
- getLicenseCheckResults: () => mockLicenseCheckResults,
- }),
- },
- },
- },
- };
- });
-
- it('only instantiates one instance per server', () => {
- const firstInstance = licensePreRoutingFactory(mockServer);
- const secondInstance = licensePreRoutingFactory(mockServer);
-
- expect(firstInstance).to.be(secondInstance);
- });
-
- describe('isAvailable is false', () => {
- beforeEach(() => {
- mockLicenseCheckResults = {
- isAvailable: false,
- };
- });
-
- it('replies with 403', () => {
- const licensePreRouting = licensePreRoutingFactory(mockServer);
- const stubRequest = {};
- expect(() => licensePreRouting(stubRequest)).to.throwException(response => {
- expect(response).to.be.an(Error);
- expect(response.isBoom).to.be(true);
- expect(response.output.statusCode).to.be(403);
- });
- });
- });
-
- describe('isAvailable is true', () => {
- beforeEach(() => {
- mockLicenseCheckResults = {
- isAvailable: true,
- };
- });
-
- it('replies with nothing', () => {
- const licensePreRouting = licensePreRoutingFactory(mockServer);
- const stubRequest = {};
- const response = licensePreRouting(stubRequest);
- expect(response).to.be(null);
- });
- });
- });
-});
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/license_pre_routing_factory/license_pre_routing_factory.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/lib/license_pre_routing_factory/license_pre_routing_factory.ts
deleted file mode 100644
index e348125967c14..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/license_pre_routing_factory/license_pre_routing_factory.ts
+++ /dev/null
@@ -1,29 +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.
- */
-
-import { once } from 'lodash';
-import { Legacy } from 'kibana';
-
-import { PLUGIN } from '../../../common/constants';
-import { wrapCustomError } from '../error_wrappers';
-
-export const licensePreRoutingFactory = once((server: Legacy.Server) => {
- const xpackMainPlugin = server.plugins.xpack_main;
-
- // License checking and enable/disable logic
- function licensePreRouting() {
- const licenseCheckResults = xpackMainPlugin.info.feature(PLUGIN.ID).getLicenseCheckResults();
- if (!licenseCheckResults.isAvailable) {
- const error = new Error(licenseCheckResults.message);
- const statusCode = 403;
- throw wrapCustomError(error, statusCode);
- }
-
- return null;
- }
-
- return licensePreRouting;
-});
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/register_license_checker/index.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/lib/register_license_checker/index.ts
deleted file mode 100644
index 7b0f97c38d129..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/register_license_checker/index.ts
+++ /dev/null
@@ -1,7 +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 { registerLicenseChecker } from './register_license_checker';
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/register_license_checker/register_license_checker.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/lib/register_license_checker/register_license_checker.ts
deleted file mode 100644
index 8e3b89fa20e33..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/register_license_checker/register_license_checker.ts
+++ /dev/null
@@ -1,23 +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.
- */
-
-import { Legacy } from 'kibana';
-// @ts-ignore
-import { mirrorPluginStatus } from '../../../../../server/lib/mirror_plugin_status';
-import { PLUGIN } from '../../../common/constants';
-import { checkLicense } from '../check_license';
-
-export function registerLicenseChecker(server: Legacy.Server) {
- const xpackMainPlugin = server.plugins.xpack_main as any;
- const ilmPlugin = (server.plugins as any).index_lifecycle_management;
-
- mirrorPluginStatus(xpackMainPlugin, ilmPlugin);
- xpackMainPlugin.status.once('green', () => {
- // Register a function that is called whenever the xpack info changes,
- // to re-compute the license check results for this plugin
- xpackMainPlugin.info.feature(PLUGIN.ID).registerLicenseCheckResultsGenerator(checkLicense);
- });
-}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/index/index.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/index/index.ts
deleted file mode 100644
index 82fb2e3b2a372..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/index/index.ts
+++ /dev/null
@@ -1,7 +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 { registerIndexRoutes } from './register_index_routes';
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/index/register_add_policy_route.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/index/register_add_policy_route.ts
deleted file mode 100644
index c3e235220931c..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/index/register_add_policy_route.ts
+++ /dev/null
@@ -1,58 +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.
- */
-
-import { callWithRequestFactory } from '../../../lib/call_with_request_factory';
-import { isEsError } from '../../../lib/is_es_error';
-import { wrapEsError, wrapUnknownError } from '../../../lib/error_wrappers';
-import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory';
-
-async function addLifecyclePolicy(
- callWithRequest: any,
- indexName: string,
- policyName: string,
- alias: string
-) {
- const body = {
- lifecycle: {
- name: policyName,
- rollover_alias: alias,
- },
- };
-
- const params = {
- method: 'PUT',
- path: `/${encodeURIComponent(indexName)}/_settings`,
- body,
- };
-
- return callWithRequest('transport.request', params);
-}
-
-export function registerAddPolicyRoute(server: any) {
- const licensePreRouting = licensePreRoutingFactory(server);
-
- server.route({
- path: '/api/index_lifecycle_management/index/add',
- method: 'POST',
- handler: async (request: any) => {
- const callWithRequest = callWithRequestFactory(server, request);
- const { indexName, policyName, alias } = request.payload as any;
- try {
- const response = await addLifecyclePolicy(callWithRequest, indexName, policyName, alias);
- return response;
- } catch (err) {
- if (isEsError(err)) {
- return wrapEsError(err);
- }
-
- return wrapUnknownError(err);
- }
- },
- config: {
- pre: [licensePreRouting],
- },
- });
-}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/index/register_remove_route.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/index/register_remove_route.ts
deleted file mode 100644
index ed3b5a97a3b42..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/index/register_remove_route.ts
+++ /dev/null
@@ -1,51 +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.
- */
-
-import { callWithRequestFactory } from '../../../lib/call_with_request_factory';
-import { isEsError } from '../../../lib/is_es_error';
-import { wrapEsError, wrapUnknownError } from '../../../lib/error_wrappers';
-import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory';
-
-async function removeLifecycle(callWithRequest: any, indexNames: string[]) {
- const responses = [];
- for (let i = 0; i < indexNames.length; i++) {
- const indexName = indexNames[i];
- const params = {
- method: 'POST',
- path: `/${encodeURIComponent(indexName)}/_ilm/remove`,
- ignore: [404],
- };
-
- responses.push(callWithRequest('transport.request', params));
- }
- return Promise.all(responses);
-}
-
-export function registerRemoveRoute(server: any) {
- const licensePreRouting = licensePreRoutingFactory(server);
-
- server.route({
- path: '/api/index_lifecycle_management/index/remove',
- method: 'POST',
- handler: async (request: any) => {
- const callWithRequest = callWithRequestFactory(server, request);
-
- try {
- const response = await removeLifecycle(callWithRequest, request.payload.indexNames);
- return response;
- } catch (err) {
- if (isEsError(err)) {
- return wrapEsError(err);
- }
-
- return wrapUnknownError(err);
- }
- },
- config: {
- pre: [licensePreRouting],
- },
- });
-}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/index/register_retry_route.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/index/register_retry_route.ts
deleted file mode 100644
index 89278edbecea2..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/index/register_retry_route.ts
+++ /dev/null
@@ -1,51 +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.
- */
-
-import { callWithRequestFactory } from '../../../lib/call_with_request_factory';
-import { isEsError } from '../../../lib/is_es_error';
-import { wrapEsError, wrapUnknownError } from '../../../lib/error_wrappers';
-import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory';
-
-async function retryLifecycle(callWithRequest: any, indexNames: string[]) {
- const responses = [];
- for (let i = 0; i < indexNames.length; i++) {
- const indexName = indexNames[i];
- const params = {
- method: 'POST',
- path: `/${encodeURIComponent(indexName)}/_ilm/retry`,
- ignore: [404],
- };
-
- responses.push(callWithRequest('transport.request', params));
- }
- return Promise.all(responses);
-}
-
-export function registerRetryRoute(server: any) {
- const licensePreRouting = licensePreRoutingFactory(server);
-
- server.route({
- path: '/api/index_lifecycle_management/index/retry',
- method: 'POST',
- handler: async (request: any) => {
- const callWithRequest = callWithRequestFactory(server, request);
-
- try {
- const response = await retryLifecycle(callWithRequest, request.payload.indexNames);
- return response;
- } catch (err) {
- if (isEsError(err)) {
- return wrapEsError(err);
- }
-
- return wrapUnknownError(err);
- }
- },
- config: {
- pre: [licensePreRouting],
- },
- });
-}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/nodes/constants.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/nodes/constants.ts
deleted file mode 100644
index 4392dacac8fa4..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/nodes/constants.ts
+++ /dev/null
@@ -1,15 +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 NODE_ATTRS_KEYS_TO_IGNORE: string[] = [
- 'ml.enabled',
- 'ml.machine_memory',
- 'ml.max_open_jobs',
- // Used by ML to identify nodes that have transform enabled:
- // https://github.com/elastic/elasticsearch/pull/52712/files#diff-225cc2c1291b4c60a8c3412a619094e1R147
- 'transform.node',
- 'xpack.installed',
-];
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/nodes/index.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/nodes/index.ts
deleted file mode 100644
index ef0ac271ae60e..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/nodes/index.ts
+++ /dev/null
@@ -1,7 +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 { registerNodesRoutes } from './register_nodes_routes';
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/nodes/register_details_route.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/nodes/register_details_route.ts
deleted file mode 100644
index c2c3f8bf07028..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/nodes/register_details_route.ts
+++ /dev/null
@@ -1,61 +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.
- */
-
-import { callWithRequestFactory } from '../../../lib/call_with_request_factory';
-import { isEsError } from '../../../lib/is_es_error';
-import { wrapEsError, wrapUnknownError } from '../../../lib/error_wrappers';
-import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory';
-
-function findMatchingNodes(stats: any, nodeAttrs: string): any {
- return Object.entries(stats.nodes).reduce((accum: any[], [nodeId, nodeStats]: [any, any]) => {
- const attributes = nodeStats.attributes || {};
- for (const [key, value] of Object.entries(attributes)) {
- if (`${key}:${value}` === nodeAttrs) {
- accum.push({
- nodeId,
- stats: nodeStats,
- });
- break;
- }
- }
- return accum;
- }, []);
-}
-
-async function fetchNodeStats(callWithRequest: any): Promise {
- const params = {
- format: 'json',
- };
-
- return await callWithRequest('nodes.stats', params);
-}
-
-export function registerDetailsRoute(server: any) {
- const licensePreRouting = licensePreRoutingFactory(server);
-
- server.route({
- path: '/api/index_lifecycle_management/nodes/{nodeAttrs}/details',
- method: 'GET',
- handler: async (request: any) => {
- const callWithRequest = callWithRequestFactory(server, request);
-
- try {
- const stats = await fetchNodeStats(callWithRequest);
- const response = findMatchingNodes(stats, request.params.nodeAttrs);
- return response;
- } catch (err) {
- if (isEsError(err)) {
- return wrapEsError(err);
- }
-
- return wrapUnknownError(err);
- }
- },
- config: {
- pre: [licensePreRouting],
- },
- });
-}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/nodes/register_list_route.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/nodes/register_list_route.ts
deleted file mode 100644
index edbe4289ed83c..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/nodes/register_list_route.ts
+++ /dev/null
@@ -1,63 +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.
- */
-
-import { callWithRequestFactory } from '../../../lib/call_with_request_factory';
-import { isEsError } from '../../../lib/is_es_error';
-import { wrapEsError, wrapUnknownError } from '../../../lib/error_wrappers';
-import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory';
-import { NODE_ATTRS_KEYS_TO_IGNORE } from './constants';
-
-function convertStatsIntoList(stats: any, attributesToBeFiltered: string[]): any {
- return Object.entries(stats.nodes).reduce((accum: any, [nodeId, nodeStats]: [any, any]) => {
- const attributes = nodeStats.attributes || {};
- for (const [key, value] of Object.entries(attributes)) {
- if (!attributesToBeFiltered.includes(key)) {
- const attributeString = `${key}:${value}`;
- accum[attributeString] = accum[attributeString] || [];
- accum[attributeString].push(nodeId);
- }
- }
- return accum;
- }, {});
-}
-
-async function fetchNodeStats(callWithRequest: any): Promise {
- const params = {
- format: 'json',
- };
-
- return await callWithRequest('nodes.stats', params);
-}
-
-export function registerListRoute(server: any) {
- const config = server.config();
- const filteredNodeAttributes = config.get('xpack.ilm.filteredNodeAttributes');
- const attributesToBeFiltered = [...NODE_ATTRS_KEYS_TO_IGNORE, ...filteredNodeAttributes];
- const licensePreRouting = licensePreRoutingFactory(server);
-
- server.route({
- path: '/api/index_lifecycle_management/nodes/list',
- method: 'GET',
- handler: async (request: any) => {
- const callWithRequest = callWithRequestFactory(server, request);
-
- try {
- const stats = await fetchNodeStats(callWithRequest);
- const response = convertStatsIntoList(stats, attributesToBeFiltered);
- return response;
- } catch (err) {
- if (isEsError(err)) {
- return wrapEsError(err);
- }
-
- return wrapUnknownError(err);
- }
- },
- config: {
- pre: [licensePreRouting],
- },
- });
-}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/policies/index.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/policies/index.ts
deleted file mode 100644
index 7c6103a3389ab..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/policies/index.ts
+++ /dev/null
@@ -1,7 +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 { registerPoliciesRoutes } from './register_policies_routes';
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/policies/register_create_route.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/policies/register_create_route.ts
deleted file mode 100644
index f6bc96dd498a4..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/policies/register_create_route.ts
+++ /dev/null
@@ -1,52 +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.
- */
-
-import { callWithRequestFactory } from '../../../lib/call_with_request_factory';
-import { isEsError } from '../../../lib/is_es_error';
-import { wrapEsError, wrapUnknownError } from '../../../lib/error_wrappers';
-import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory';
-
-async function createPolicy(callWithRequest: any, policy: any): Promise {
- const body = {
- policy: {
- phases: policy.phases,
- },
- };
- const params = {
- method: 'PUT',
- path: `/_ilm/policy/${encodeURIComponent(policy.name)}`,
- ignore: [404],
- body,
- };
-
- return await callWithRequest('transport.request', params);
-}
-
-export function registerCreateRoute(server: any) {
- const licensePreRouting = licensePreRoutingFactory(server);
-
- server.route({
- path: '/api/index_lifecycle_management/policies',
- method: 'POST',
- handler: async (request: any) => {
- const callWithRequest = callWithRequestFactory(server, request);
-
- try {
- const response = await createPolicy(callWithRequest, request.payload);
- return response;
- } catch (err) {
- if (isEsError(err)) {
- return wrapEsError(err);
- }
-
- return wrapUnknownError(err);
- }
- },
- config: {
- pre: [licensePreRouting],
- },
- });
-}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/policies/register_delete_route.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/policies/register_delete_route.ts
deleted file mode 100644
index c84f2efd92d8f..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/policies/register_delete_route.ts
+++ /dev/null
@@ -1,46 +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.
- */
-
-import { callWithRequestFactory } from '../../../lib/call_with_request_factory';
-import { isEsError } from '../../../lib/is_es_error';
-import { wrapEsError, wrapUnknownError } from '../../../lib/error_wrappers';
-import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory';
-
-async function deletePolicies(policyNames: string, callWithRequest: any): Promise {
- const params = {
- method: 'DELETE',
- path: `/_ilm/policy/${encodeURIComponent(policyNames)}`,
- // we allow 404 since they may have no policies
- ignore: [404],
- };
-
- return await callWithRequest('transport.request', params);
-}
-
-export function registerDeleteRoute(server: any) {
- const licensePreRouting = licensePreRoutingFactory(server);
-
- server.route({
- path: '/api/index_lifecycle_management/policies/{policyNames}',
- method: 'DELETE',
- handler: async (request: any) => {
- const callWithRequest = callWithRequestFactory(server, request);
- const { policyNames } = request.params;
- try {
- await deletePolicies(policyNames, callWithRequest);
- return {};
- } catch (err) {
- if (isEsError(err)) {
- return wrapEsError(err);
- }
- return wrapUnknownError(err);
- }
- },
- config: {
- pre: [licensePreRouting],
- },
- });
-}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/policies/register_fetch_route.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/policies/register_fetch_route.ts
deleted file mode 100644
index c65f849a47d87..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/policies/register_fetch_route.ts
+++ /dev/null
@@ -1,84 +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.
- */
-
-import { callWithRequestFactory } from '../../../lib/call_with_request_factory';
-import { isEsError } from '../../../lib/is_es_error';
-import { wrapEsError, wrapUnknownError } from '../../../lib/error_wrappers';
-import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory';
-
-function formatPolicies(policiesMap: any): any {
- if (policiesMap.status === 404) {
- return [];
- }
-
- return Object.keys(policiesMap).reduce((accum: any[], lifecycleName: string) => {
- const policyEntry = policiesMap[lifecycleName];
- accum.push({
- ...policyEntry,
- name: lifecycleName,
- });
- return accum;
- }, []);
-}
-
-async function fetchPolicies(callWithRequest: any): Promise {
- const params = {
- method: 'GET',
- path: '/_ilm/policy',
- // we allow 404 since they may have no policies
- ignore: [404],
- };
-
- return await callWithRequest('transport.request', params);
-}
-async function addLinkedIndices(policiesMap: any, callWithRequest: any) {
- if (policiesMap.status === 404) {
- return policiesMap;
- }
- const params = {
- method: 'GET',
- path: '/*/_ilm/explain',
- // we allow 404 since they may have no policies
- ignore: [404],
- };
-
- const policyExplanation: any = await callWithRequest('transport.request', params);
- Object.entries(policyExplanation.indices).forEach(([indexName, { policy }]: [string, any]) => {
- if (policy && policiesMap[policy]) {
- policiesMap[policy].linkedIndices = policiesMap[policy].linkedIndices || [];
- policiesMap[policy].linkedIndices.push(indexName);
- }
- });
-}
-
-export function registerFetchRoute(server: any) {
- const licensePreRouting = licensePreRoutingFactory(server);
-
- server.route({
- path: '/api/index_lifecycle_management/policies',
- method: 'GET',
- handler: async (request: any) => {
- const callWithRequest = callWithRequestFactory(server, request);
- const { withIndices } = request.query;
- try {
- const policiesMap = await fetchPolicies(callWithRequest);
- if (withIndices) {
- await addLinkedIndices(policiesMap, callWithRequest);
- }
- return formatPolicies(policiesMap);
- } catch (err) {
- if (isEsError(err)) {
- return wrapEsError(err);
- }
-
- return wrapUnknownError(err);
- }
- },
- config: {
- pre: [licensePreRouting],
- },
- });
-}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/templates/index.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/templates/index.ts
deleted file mode 100644
index dc9a0acaaf09b..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/templates/index.ts
+++ /dev/null
@@ -1,7 +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 { registerTemplatesRoutes } from './register_templates_routes';
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/templates/register_add_policy_route.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/templates/register_add_policy_route.ts
deleted file mode 100644
index 57e5a91f60f5b..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/templates/register_add_policy_route.ts
+++ /dev/null
@@ -1,67 +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.
- */
-
-import { merge } from 'lodash';
-
-import { callWithRequestFactory } from '../../../lib/call_with_request_factory';
-import { isEsError } from '../../../lib/is_es_error';
-import { wrapEsError, wrapUnknownError } from '../../../lib/error_wrappers';
-import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory';
-
-async function getIndexTemplate(callWithRequest: any, templateName: string): Promise {
- const response = await callWithRequest('indices.getTemplate', { name: templateName });
- return response[templateName];
-}
-
-async function updateIndexTemplate(callWithRequest: any, indexTemplatePatch: any): Promise {
- // Fetch existing template
- const template = await getIndexTemplate(callWithRequest, indexTemplatePatch.templateName);
- merge(template, {
- settings: {
- index: {
- lifecycle: {
- name: indexTemplatePatch.policyName,
- rollover_alias: indexTemplatePatch.aliasName,
- },
- },
- },
- });
-
- const params = {
- method: 'PUT',
- path: `/_template/${encodeURIComponent(indexTemplatePatch.templateName)}`,
- ignore: [404],
- body: template,
- };
-
- return await callWithRequest('transport.request', params);
-}
-
-export function registerAddPolicyRoute(server: any) {
- const licensePreRouting = licensePreRoutingFactory(server);
-
- server.route({
- path: '/api/index_lifecycle_management/template',
- method: 'POST',
- handler: async (request: any) => {
- const callWithRequest = callWithRequestFactory(server, request);
-
- try {
- const response = await updateIndexTemplate(callWithRequest, request.payload);
- return response;
- } catch (err) {
- if (isEsError(err)) {
- return wrapEsError(err);
- }
-
- return wrapUnknownError(err);
- }
- },
- config: {
- pre: [licensePreRouting],
- },
- });
-}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/templates/register_get_route.ts b/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/templates/register_get_route.ts
deleted file mode 100644
index 3edaea6e15818..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/templates/register_get_route.ts
+++ /dev/null
@@ -1,48 +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.
- */
-
-import { callWithRequestFactory } from '../../../lib/call_with_request_factory';
-import { isEsError } from '../../../lib/is_es_error';
-import { wrapEsError, wrapUnknownError } from '../../../lib/error_wrappers';
-import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory';
-
-async function fetchTemplate(callWithRequest: any, templateName: string): Promise {
- const params = {
- method: 'GET',
- path: `/_template/${encodeURIComponent(templateName)}`,
- // we allow 404 incase the user shutdown security in-between the check and now
- ignore: [404],
- };
-
- return await callWithRequest('transport.request', params);
-}
-
-export function registerGetRoute(server: any) {
- const licensePreRouting = licensePreRoutingFactory(server);
-
- server.route({
- path: '/api/index_lifecycle_management/templates/{templateName}',
- method: 'GET',
- handler: async (request: any) => {
- const callWithRequest = callWithRequestFactory(server, request);
- const templateName = request.params.templateName;
-
- try {
- const template = await fetchTemplate(callWithRequest, templateName);
- return template[templateName];
- } catch (err) {
- if (isEsError(err)) {
- return wrapEsError(err);
- }
-
- return wrapUnknownError(err);
- }
- },
- config: {
- pre: [licensePreRouting],
- },
- });
-}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/shim.ts b/x-pack/legacy/plugins/index_lifecycle_management/shim.ts
deleted file mode 100644
index 18b3d9ef28b6a..0000000000000
--- a/x-pack/legacy/plugins/index_lifecycle_management/shim.ts
+++ /dev/null
@@ -1,17 +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.
- */
-
-import { Legacy } from 'kibana';
-
-export interface LegacySetup {
- server: Legacy.Server;
-}
-
-export function createShim(server: Legacy.Server): LegacySetup {
- return {
- server,
- };
-}
diff --git a/x-pack/legacy/plugins/index_management/index.ts b/x-pack/legacy/plugins/index_management/index.ts
index 9eba98a526d2b..afca15203b970 100644
--- a/x-pack/legacy/plugins/index_management/index.ts
+++ b/x-pack/legacy/plugins/index_management/index.ts
@@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
+// TODO: Remove this once CCR is migrated to the plugins directory.
export function indexManagement(kibana: any) {
return new kibana.Plugin({
id: 'index_management',
diff --git a/x-pack/legacy/plugins/rollup/public/plugin.ts b/x-pack/legacy/plugins/rollup/public/plugin.ts
index 5782e88c3448b..17ec8a5a4aedf 100644
--- a/x-pack/legacy/plugins/rollup/public/plugin.ts
+++ b/x-pack/legacy/plugins/rollup/public/plugin.ts
@@ -24,7 +24,7 @@ import {
// @ts-ignore
import { CRUD_APP_BASE_PATH } from './crud_app/constants';
import { ManagementSetup } from '../../../../../src/plugins/management/public';
-import { IndexMgmtSetup } from '../../../../plugins/index_management/public';
+import { IndexManagementPluginSetup } from '../../../../plugins/index_management/public';
import { IndexPatternManagementSetup } from '../../../../../src/plugins/index_pattern_management/public';
import { search } from '../../../../../src/plugins/data/public';
// @ts-ignore
@@ -35,7 +35,7 @@ import { renderApp } from './application';
export interface RollupPluginSetupDependencies {
home?: HomePublicPluginSetup;
management: ManagementSetup;
- indexManagement?: IndexMgmtSetup;
+ indexManagement?: IndexManagementPluginSetup;
indexPatternManagement: IndexPatternManagementSetup;
}
diff --git a/x-pack/legacy/plugins/rollup/server/plugin.ts b/x-pack/legacy/plugins/rollup/server/plugin.ts
index 090cb8a47377a..5f29ad160e052 100644
--- a/x-pack/legacy/plugins/rollup/server/plugin.ts
+++ b/x-pack/legacy/plugins/rollup/server/plugin.ts
@@ -9,7 +9,7 @@ import { i18n } from '@kbn/i18n';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
import { VisTypeTimeseriesSetup } from 'src/plugins/vis_type_timeseries/server';
-import { IndexMgmtSetup } from '../../../../plugins/index_management/server';
+import { IndexManagementPluginSetup } from '../../../../plugins/index_management/server';
import { registerLicenseChecker } from '../../../server/lib/register_license_checker';
import { PLUGIN } from '../common';
import { ServerShim, RouteDependencies } from './types';
@@ -44,7 +44,7 @@ export class RollupsServerPlugin implements Plugin {
__LEGACY: ServerShim;
usageCollection?: UsageCollectionSetup;
metrics?: VisTypeTimeseriesSetup;
- indexManagement?: IndexMgmtSetup;
+ indexManagement?: IndexManagementPluginSetup;
}
) {
const elasticsearch = await elasticsearchService.adminClient;
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/__jest__/__snapshots__/extend_index_management.test.js.snap b/x-pack/plugins/index_lifecycle_management/__jest__/__snapshots__/extend_index_management.test.js.snap
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/__jest__/__snapshots__/extend_index_management.test.js.snap
rename to x-pack/plugins/index_lifecycle_management/__jest__/__snapshots__/extend_index_management.test.js.snap
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/__jest__/components/__snapshots__/policy_table.test.js.snap b/x-pack/plugins/index_lifecycle_management/__jest__/components/__snapshots__/policy_table.test.js.snap
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/__jest__/components/__snapshots__/policy_table.test.js.snap
rename to x-pack/plugins/index_lifecycle_management/__jest__/components/__snapshots__/policy_table.test.js.snap
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/__jest__/components/edit_policy.test.js b/x-pack/plugins/index_lifecycle_management/__jest__/components/edit_policy.test.js
similarity index 96%
rename from x-pack/legacy/plugins/index_lifecycle_management/__jest__/components/edit_policy.test.js
rename to x-pack/plugins/index_lifecycle_management/__jest__/components/edit_policy.test.js
index 9d143c4d3fc8e..bf4de823f1833 100644
--- a/x-pack/legacy/plugins/index_lifecycle_management/__jest__/components/edit_policy.test.js
+++ b/x-pack/plugins/index_lifecycle_management/__jest__/components/edit_policy.test.js
@@ -13,13 +13,13 @@ import axiosXhrAdapter from 'axios/lib/adapters/xhr';
import sinon from 'sinon';
import { findTestSubject } from '@elastic/eui/lib/test';
-import { mountWithIntl } from '../../../../../test_utils/enzyme_helpers';
-import { fetchedPolicies, fetchedNodes } from '../../public/np_ready/application/store/actions';
-import { indexLifecycleManagementStore } from '../../public/np_ready/application/store';
-import { EditPolicy } from '../../public/np_ready/application/sections/edit_policy';
-import { init as initHttp } from '../../public/np_ready/application/services/http';
-import { init as initUiMetric } from '../../public/np_ready/application/services/ui_metric';
-import { init as initNotification } from '../../public/np_ready/application/services/notification';
+import { mountWithIntl } from '../../../../test_utils/enzyme_helpers';
+import { fetchedPolicies, fetchedNodes } from '../../public/application/store/actions';
+import { indexLifecycleManagementStore } from '../../public/application/store';
+import { EditPolicy } from '../../public/application/sections/edit_policy';
+import { init as initHttp } from '../../public/application/services/http';
+import { init as initUiMetric } from '../../public/application/services/ui_metric';
+import { init as initNotification } from '../../public/application/services/notification';
import {
positiveNumbersAboveZeroErrorMessage,
positiveNumberRequiredMessage,
@@ -33,16 +33,14 @@ import {
policyNameMustBeDifferentErrorMessage,
policyNameAlreadyUsedErrorMessage,
maximumDocumentsRequiredMessage,
-} from '../../public/np_ready/application/store/selectors/lifecycle';
+} from '../../public/application/store/selectors/lifecycle';
initHttp(axios.create({ adapter: axiosXhrAdapter }), path => path);
-initUiMetric(() => () => {});
+initUiMetric({ reportUiStats: () => {} });
initNotification({
addDanger: () => {},
});
-jest.mock('ui/new_platform');
-
let server;
let store;
const policy = {
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/__jest__/components/policy_table.test.js b/x-pack/plugins/index_lifecycle_management/__jest__/components/policy_table.test.js
similarity index 91%
rename from x-pack/legacy/plugins/index_lifecycle_management/__jest__/components/policy_table.test.js
rename to x-pack/plugins/index_lifecycle_management/__jest__/components/policy_table.test.js
index a3a9c5e59bfa4..78c5c181eea62 100644
--- a/x-pack/legacy/plugins/index_lifecycle_management/__jest__/components/policy_table.test.js
+++ b/x-pack/plugins/index_lifecycle_management/__jest__/components/policy_table.test.js
@@ -12,17 +12,15 @@ import axiosXhrAdapter from 'axios/lib/adapters/xhr';
import sinon from 'sinon';
import { findTestSubject, takeMountedSnapshot } from '@elastic/eui/lib/test';
-import { mountWithIntl } from '../../../../../test_utils/enzyme_helpers';
-import { fetchedPolicies } from '../../public/np_ready/application/store/actions';
-import { indexLifecycleManagementStore } from '../../public/np_ready/application/store';
-import { PolicyTable } from '../../public/np_ready/application/sections/policy_table';
-import { init as initHttp } from '../../public/np_ready/application/services/http';
-import { init as initUiMetric } from '../../public/np_ready/application/services/ui_metric';
+import { mountWithIntl } from '../../../../test_utils/enzyme_helpers';
+import { fetchedPolicies } from '../../public/application/store/actions';
+import { indexLifecycleManagementStore } from '../../public/application/store';
+import { PolicyTable } from '../../public/application/sections/policy_table';
+import { init as initHttp } from '../../public/application/services/http';
+import { init as initUiMetric } from '../../public/application/services/ui_metric';
initHttp(axios.create({ adapter: axiosXhrAdapter }), path => path);
-initUiMetric(() => () => {});
-
-jest.mock('ui/new_platform');
+initUiMetric({ reportUiStats: () => {} });
let server = null;
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/__jest__/extend_index_management.test.js b/x-pack/plugins/index_lifecycle_management/__jest__/extend_index_management.test.js
similarity index 93%
rename from x-pack/legacy/plugins/index_lifecycle_management/__jest__/extend_index_management.test.js
rename to x-pack/plugins/index_lifecycle_management/__jest__/extend_index_management.test.js
index d2619778617c3..900de27ca36ab 100644
--- a/x-pack/legacy/plugins/index_lifecycle_management/__jest__/extend_index_management.test.js
+++ b/x-pack/plugins/index_lifecycle_management/__jest__/extend_index_management.test.js
@@ -8,7 +8,7 @@ import moment from 'moment-timezone';
import axios from 'axios';
import axiosXhrAdapter from 'axios/lib/adapters/xhr';
-import { mountWithIntl } from '../../../../test_utils/enzyme_helpers';
+import { mountWithIntl } from '../../../test_utils/enzyme_helpers';
import {
retryLifecycleActionExtension,
removeLifecyclePolicyActionExtension,
@@ -16,21 +16,18 @@ import {
ilmBannerExtension,
ilmFilterExtension,
ilmSummaryExtension,
-} from '../public/np_ready/extend_index_management';
-import { init as initHttp } from '../public/np_ready/application/services/http';
-import { init as initUiMetric } from '../public/np_ready/application/services/ui_metric';
+} from '../public/extend_index_management';
+import { init as initHttp } from '../public/application/services/http';
+import { init as initUiMetric } from '../public/application/services/ui_metric';
// We need to init the http with a mock for any tests that depend upon the http service.
// For example, add_lifecycle_confirm_modal makes an API request in its componentDidMount
// lifecycle method. If we don't mock this, CI will fail with "Call retries were exceeded".
initHttp(axios.create({ adapter: axiosXhrAdapter }), path => path);
-initUiMetric(() => () => {});
+initUiMetric({ reportUiStats: () => {} });
-jest.mock('ui/new_platform');
-jest.mock('../../../../plugins/index_management/public', async () => {
- const { indexManagementMock } = await import(
- '../../../../plugins/index_management/public/mocks.ts'
- );
+jest.mock('../../../plugins/index_management/public', async () => {
+ const { indexManagementMock } = await import('../../../plugins/index_management/public/mocks.ts');
return indexManagementMock.createSetup();
});
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/common/constants/index.ts b/x-pack/plugins/index_lifecycle_management/common/constants/index.ts
similarity index 72%
rename from x-pack/legacy/plugins/index_lifecycle_management/common/constants/index.ts
rename to x-pack/plugins/index_lifecycle_management/common/constants/index.ts
index 9193efb561a0f..700039985eaf5 100644
--- a/x-pack/legacy/plugins/index_lifecycle_management/common/constants/index.ts
+++ b/x-pack/plugins/index_lifecycle_management/common/constants/index.ts
@@ -5,12 +5,18 @@
*/
import { i18n } from '@kbn/i18n';
+import { LicenseType } from '../../../licensing/common/types';
+
+const basicLicense: LicenseType = 'basic';
export const PLUGIN = {
ID: 'index_lifecycle_management',
+ minimumLicenseType: basicLicense,
TITLE: i18n.translate('xpack.indexLifecycleMgmt.appTitle', {
defaultMessage: 'Index Lifecycle Policies',
}),
};
export const BASE_PATH = '/management/elasticsearch/index_lifecycle_management/';
+
+export const API_BASE_PATH = '/api/index_lifecycle_management';
diff --git a/x-pack/plugins/index_lifecycle_management/kibana.json b/x-pack/plugins/index_lifecycle_management/kibana.json
new file mode 100644
index 0000000000000..6385646b95789
--- /dev/null
+++ b/x-pack/plugins/index_lifecycle_management/kibana.json
@@ -0,0 +1,16 @@
+{
+ "id": "indexLifecycleManagement",
+ "version": "kibana",
+ "server": true,
+ "ui": true,
+ "requiredPlugins": [
+ "home",
+ "licensing",
+ "management"
+ ],
+ "optionalPlugins": [
+ "usageCollection",
+ "indexManagement"
+ ],
+ "configPath": ["xpack", "ilm"]
+}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/app.tsx b/x-pack/plugins/index_lifecycle_management/public/application/app.tsx
similarity index 94%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/app.tsx
rename to x-pack/plugins/index_lifecycle_management/public/application/app.tsx
index 6738d7caa4444..993dced20bbe6 100644
--- a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/app.tsx
+++ b/x-pack/plugins/index_lifecycle_management/public/application/app.tsx
@@ -8,7 +8,7 @@ import React, { useEffect } from 'react';
import { HashRouter, Switch, Route, Redirect } from 'react-router-dom';
import { METRIC_TYPE } from '@kbn/analytics';
-import { BASE_PATH } from '../../../common/constants';
+import { BASE_PATH } from '../../common/constants';
import { UIM_APP_LOAD } from './constants';
import { EditPolicy } from './sections/edit_policy';
import { PolicyTable } from './sections/policy_table';
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/constants/index.ts b/x-pack/plugins/index_lifecycle_management/public/application/constants/index.ts
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/constants/index.ts
rename to x-pack/plugins/index_lifecycle_management/public/application/constants/index.ts
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/constants/ui_metric.ts b/x-pack/plugins/index_lifecycle_management/public/application/constants/ui_metric.ts
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/constants/ui_metric.ts
rename to x-pack/plugins/index_lifecycle_management/public/application/constants/ui_metric.ts
diff --git a/x-pack/plugins/index_lifecycle_management/public/application/index.tsx b/x-pack/plugins/index_lifecycle_management/public/application/index.tsx
new file mode 100644
index 0000000000000..a7d88d31e58fc
--- /dev/null
+++ b/x-pack/plugins/index_lifecycle_management/public/application/index.tsx
@@ -0,0 +1,27 @@
+/*
+ * 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 React from 'react';
+import { render, unmountComponentAtNode } from 'react-dom';
+import { Provider } from 'react-redux';
+import { I18nStart } from 'kibana/public';
+import { UnmountCallback } from 'src/core/public';
+
+import { App } from './app';
+import { indexLifecycleManagementStore } from './store';
+
+export const renderApp = (element: Element, I18nContext: I18nStart['Context']): UnmountCallback => {
+ render(
+
+
+
+
+ ,
+ element
+ );
+
+ return () => unmountComponentAtNode(element);
+};
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/components/active_badge.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/components/active_badge.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/components/active_badge.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/components/active_badge.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/components/index.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/components/index.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/components/index.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/components/index.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/components/learn_more_link.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/components/learn_more_link.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/components/learn_more_link.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/components/learn_more_link.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/components/optional_label.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/components/optional_label.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/components/optional_label.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/components/optional_label.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/components/phase_error_message.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/components/phase_error_message.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/components/phase_error_message.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/components/phase_error_message.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/cold_phase/cold_phase.container.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/cold_phase/cold_phase.container.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/cold_phase/cold_phase.container.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/cold_phase/cold_phase.container.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/cold_phase/cold_phase.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/cold_phase/cold_phase.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/cold_phase/cold_phase.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/cold_phase/cold_phase.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/cold_phase/index.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/cold_phase/index.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/cold_phase/index.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/cold_phase/index.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/delete_phase/delete_phase.container.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/delete_phase/delete_phase.container.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/delete_phase/delete_phase.container.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/delete_phase/delete_phase.container.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/delete_phase/delete_phase.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/delete_phase/delete_phase.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/delete_phase/delete_phase.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/delete_phase/delete_phase.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/delete_phase/index.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/delete_phase/index.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/delete_phase/index.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/delete_phase/index.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/hot_phase/hot_phase.container.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/hot_phase/hot_phase.container.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/hot_phase/hot_phase.container.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/hot_phase/hot_phase.container.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/hot_phase/hot_phase.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/hot_phase/hot_phase.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/hot_phase/hot_phase.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/hot_phase/hot_phase.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/hot_phase/index.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/hot_phase/index.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/hot_phase/index.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/hot_phase/index.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/min_age_input.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/min_age_input.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/min_age_input.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/min_age_input.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/node_allocation/index.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/node_allocation/index.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/node_allocation/index.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/node_allocation/index.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/node_allocation/node_allocation.container.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/node_allocation/node_allocation.container.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/node_allocation/node_allocation.container.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/node_allocation/node_allocation.container.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/node_allocation/node_allocation.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/node_allocation/node_allocation.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/node_allocation/node_allocation.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/node_allocation/node_allocation.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/node_attrs_details/index.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/node_attrs_details/index.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/node_attrs_details/index.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/node_attrs_details/index.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/node_attrs_details/node_attrs_details.container.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/node_attrs_details/node_attrs_details.container.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/node_attrs_details/node_attrs_details.container.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/node_attrs_details/node_attrs_details.container.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/node_attrs_details/node_attrs_details.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/node_attrs_details/node_attrs_details.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/node_attrs_details/node_attrs_details.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/node_attrs_details/node_attrs_details.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/policy_json_flyout.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/policy_json_flyout.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/policy_json_flyout.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/policy_json_flyout.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/set_priority_input.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/set_priority_input.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/set_priority_input.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/set_priority_input.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/warm_phase/index.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/warm_phase/index.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/warm_phase/index.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/warm_phase/index.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/warm_phase/warm_phase.container.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/warm_phase/warm_phase.container.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/warm_phase/warm_phase.container.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/warm_phase/warm_phase.container.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/warm_phase/warm_phase.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/warm_phase/warm_phase.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/components/warm_phase/warm_phase.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/warm_phase/warm_phase.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/edit_policy.container.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.container.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/edit_policy.container.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.container.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/edit_policy.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/edit_policy.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/form_errors.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form_errors.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/form_errors.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/form_errors.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/index.d.ts b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/index.d.ts
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/index.d.ts
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/index.d.ts
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/index.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/index.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/edit_policy/index.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/index.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/policy_table/components/no_match/components/no_match/index.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/policy_table/components/no_match/components/no_match/index.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/policy_table/components/no_match/components/no_match/index.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/policy_table/components/no_match/components/no_match/index.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/policy_table/components/no_match/components/no_match/no_match.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/policy_table/components/no_match/components/no_match/no_match.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/policy_table/components/no_match/components/no_match/no_match.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/policy_table/components/no_match/components/no_match/no_match.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/policy_table/components/no_match/index.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/policy_table/components/no_match/index.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/policy_table/components/no_match/index.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/policy_table/components/no_match/index.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/policy_table/components/policy_table/add_policy_to_template_confirm_modal.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/policy_table/components/policy_table/add_policy_to_template_confirm_modal.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/policy_table/components/policy_table/add_policy_to_template_confirm_modal.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/policy_table/components/policy_table/add_policy_to_template_confirm_modal.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/policy_table/components/policy_table/confirm_delete.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/policy_table/components/policy_table/confirm_delete.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/policy_table/components/policy_table/confirm_delete.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/policy_table/components/policy_table/confirm_delete.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/policy_table/components/policy_table/index.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/policy_table/components/policy_table/index.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/policy_table/components/policy_table/index.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/policy_table/components/policy_table/index.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/policy_table/components/policy_table/policy_table.container.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/policy_table/components/policy_table/policy_table.container.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/policy_table/components/policy_table/policy_table.container.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/policy_table/components/policy_table/policy_table.container.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/policy_table/components/policy_table/policy_table.js b/x-pack/plugins/index_lifecycle_management/public/application/sections/policy_table/components/policy_table/policy_table.js
similarity index 98%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/policy_table/components/policy_table/policy_table.js
rename to x-pack/plugins/index_lifecycle_management/public/application/sections/policy_table/components/policy_table/policy_table.js
index 903161fe094fc..d406d86bc6ce7 100644
--- a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/sections/policy_table/components/policy_table/policy_table.js
+++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/policy_table/components/policy_table/policy_table.js
@@ -37,8 +37,8 @@ import {
import { RIGHT_ALIGNMENT } from '@elastic/eui/lib/services';
-import { getIndexListUri } from '../../../../../../../../../../plugins/index_management/public';
-import { BASE_PATH } from '../../../../../../../common/constants';
+import { getIndexListUri } from '../../../../../../../index_management/public';
+import { BASE_PATH } from '../../../../../../common/constants';
import { UIM_EDIT_CLICK } from '../../../../constants';
import { getPolicyPath } from '../../../../services/navigation';
import { flattenPanelTree } from '../../../../services/flatten_panel_tree';
@@ -52,6 +52,7 @@ const COLUMNS = {
label: i18n.translate('xpack.indexLifecycleMgmt.policyTable.headers.nameHeader', {
defaultMessage: 'Name',
}),
+ width: 200,
},
linkedIndices: {
label: i18n.translate('xpack.indexLifecycleMgmt.policyTable.headers.linkedIndicesHeader', {
@@ -179,7 +180,6 @@ export class PolicyTable extends Component {
return (
/* eslint-disable-next-line @elastic/eui/href-or-on-click */
trackUiMetric('click', UIM_EDIT_CLICK)}
@@ -415,7 +415,7 @@ export class PolicyTable extends Component {
tableContent = ;
} else if (totalNumberOfPolicies > 0) {
tableContent = (
-
+
{
+ const response = await sendPost(`index/retry`, { indexNames });
+ // Only track successful actions.
+ trackUiMetric('count', UIM_INDEX_RETRY_STEP);
+ return response;
+};
+
+export const removeLifecycleForIndex = async indexNames => {
+ const response = await sendPost(`index/remove`, { indexNames });
+ // Only track successful actions.
+ trackUiMetric('count', UIM_POLICY_DETACH_INDEX);
+ return response;
+};
+
+export const addLifecyclePolicyToIndex = async body => {
+ const response = await sendPost(`index/add`, body);
+ // Only track successful actions.
+ trackUiMetric('count', UIM_POLICY_ATTACH_INDEX);
+ return response;
+};
+
+export const addLifecyclePolicyToTemplate = async body => {
+ const response = await sendPost(`template`, body);
+ // Only track successful actions.
+ trackUiMetric('count', UIM_POLICY_ATTACH_INDEX_TEMPLATE);
+ return response;
+};
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/api_errors.js b/x-pack/plugins/index_lifecycle_management/public/application/services/api_errors.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/api_errors.js
rename to x-pack/plugins/index_lifecycle_management/public/application/services/api_errors.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/documentation.ts b/x-pack/plugins/index_lifecycle_management/public/application/services/documentation.ts
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/documentation.ts
rename to x-pack/plugins/index_lifecycle_management/public/application/services/documentation.ts
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/filter_items.js b/x-pack/plugins/index_lifecycle_management/public/application/services/filter_items.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/filter_items.js
rename to x-pack/plugins/index_lifecycle_management/public/application/services/filter_items.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/find_errors.js b/x-pack/plugins/index_lifecycle_management/public/application/services/find_errors.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/find_errors.js
rename to x-pack/plugins/index_lifecycle_management/public/application/services/find_errors.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/flatten_panel_tree.js b/x-pack/plugins/index_lifecycle_management/public/application/services/flatten_panel_tree.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/flatten_panel_tree.js
rename to x-pack/plugins/index_lifecycle_management/public/application/services/flatten_panel_tree.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/http.ts b/x-pack/plugins/index_lifecycle_management/public/application/services/http.ts
similarity index 50%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/http.ts
rename to x-pack/plugins/index_lifecycle_management/public/application/services/http.ts
index bbda1ebd2e0e5..47e96ea28bb8c 100644
--- a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/http.ts
+++ b/x-pack/plugins/index_lifecycle_management/public/application/services/http.ts
@@ -20,16 +20,14 @@ function getFullPath(path: string): string {
return apiPrefix;
}
-// The extend_index_management module requires that we support an injected httpClient here.
-
-export function sendPost(path: string, payload: any, httpClient = _httpClient): any {
- return httpClient.post(getFullPath(path), { body: JSON.stringify(payload) });
+export function sendPost(path: string, payload: any): any {
+ return _httpClient.post(getFullPath(path), { body: JSON.stringify(payload) });
}
-export function sendGet(path: string, query: any, httpClient = _httpClient): any {
- return httpClient.get(getFullPath(path), { query });
+export function sendGet(path: string, query: any): any {
+ return _httpClient.get(getFullPath(path), { query });
}
-export function sendDelete(path: string, httpClient = _httpClient): any {
- return httpClient.delete(getFullPath(path));
+export function sendDelete(path: string): any {
+ return _httpClient.delete(getFullPath(path));
}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/index.js b/x-pack/plugins/index_lifecycle_management/public/application/services/index.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/index.js
rename to x-pack/plugins/index_lifecycle_management/public/application/services/index.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/navigation.ts b/x-pack/plugins/index_lifecycle_management/public/application/services/navigation.ts
similarity index 59%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/navigation.ts
rename to x-pack/plugins/index_lifecycle_management/public/application/services/navigation.ts
index 943f9a49d0ab6..2d518ebb3015e 100644
--- a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/navigation.ts
+++ b/x-pack/plugins/index_lifecycle_management/public/application/services/navigation.ts
@@ -4,18 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { BASE_PATH } from '../../../../common/constants';
-
-// This depends upon Angular, which is why we use this provider pattern to access it within
-// our React app.
-let _redirect: any;
-
-export function init(redirect: any) {
- _redirect = redirect;
-}
+import { BASE_PATH } from '../../../common/constants';
export const goToPolicyList = () => {
- _redirect(`${BASE_PATH}policies`);
+ window.location.hash = `${BASE_PATH}policies`;
};
export const getPolicyPath = (policyName: string): string => {
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/notification.ts b/x-pack/plugins/index_lifecycle_management/public/application/services/notification.ts
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/notification.ts
rename to x-pack/plugins/index_lifecycle_management/public/application/services/notification.ts
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/sort_table.js b/x-pack/plugins/index_lifecycle_management/public/application/services/sort_table.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/sort_table.js
rename to x-pack/plugins/index_lifecycle_management/public/application/services/sort_table.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/ui_metric.test.js b/x-pack/plugins/index_lifecycle_management/public/application/services/ui_metric.test.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/ui_metric.test.js
rename to x-pack/plugins/index_lifecycle_management/public/application/services/ui_metric.test.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/ui_metric.ts b/x-pack/plugins/index_lifecycle_management/public/application/services/ui_metric.ts
similarity index 85%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/ui_metric.ts
rename to x-pack/plugins/index_lifecycle_management/public/application/services/ui_metric.ts
index d9f2c26048317..ca6c0b44d5804 100644
--- a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/services/ui_metric.ts
+++ b/x-pack/plugins/index_lifecycle_management/public/application/services/ui_metric.ts
@@ -6,7 +6,8 @@
import { get } from 'lodash';
-import { createUiStatsReporter } from '../../../../../../../../src/legacy/core_plugins/ui_metric/public';
+import { UsageCollectionSetup } from 'src/plugins/usage_collection/public';
+import { UiStatsMetricType } from '@kbn/analytics';
import {
UIM_APP_NAME,
@@ -22,12 +23,10 @@ import {
import { defaultColdPhase, defaultWarmPhase, defaultHotPhase } from '../store/defaults';
-export let trackUiMetric: ReturnType;
+export let trackUiMetric: (metricType: UiStatsMetricType, eventName: string) => void;
-export function init(getReporter: typeof createUiStatsReporter): void {
- if (getReporter) {
- trackUiMetric = getReporter(UIM_APP_NAME);
- }
+export function init(usageCollection: UsageCollectionSetup): void {
+ trackUiMetric = usageCollection.reportUiStats.bind(usageCollection, UIM_APP_NAME);
}
export function getUiMetricsForPhases(phases: any): any {
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/actions/general.js b/x-pack/plugins/index_lifecycle_management/public/application/store/actions/general.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/actions/general.js
rename to x-pack/plugins/index_lifecycle_management/public/application/store/actions/general.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/actions/index.js b/x-pack/plugins/index_lifecycle_management/public/application/store/actions/index.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/actions/index.js
rename to x-pack/plugins/index_lifecycle_management/public/application/store/actions/index.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/actions/lifecycle.js b/x-pack/plugins/index_lifecycle_management/public/application/store/actions/lifecycle.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/actions/lifecycle.js
rename to x-pack/plugins/index_lifecycle_management/public/application/store/actions/lifecycle.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/actions/nodes.js b/x-pack/plugins/index_lifecycle_management/public/application/store/actions/nodes.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/actions/nodes.js
rename to x-pack/plugins/index_lifecycle_management/public/application/store/actions/nodes.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/actions/policies.js b/x-pack/plugins/index_lifecycle_management/public/application/store/actions/policies.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/actions/policies.js
rename to x-pack/plugins/index_lifecycle_management/public/application/store/actions/policies.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/defaults/cold_phase.js b/x-pack/plugins/index_lifecycle_management/public/application/store/defaults/cold_phase.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/defaults/cold_phase.js
rename to x-pack/plugins/index_lifecycle_management/public/application/store/defaults/cold_phase.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/defaults/delete_phase.js b/x-pack/plugins/index_lifecycle_management/public/application/store/defaults/delete_phase.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/defaults/delete_phase.js
rename to x-pack/plugins/index_lifecycle_management/public/application/store/defaults/delete_phase.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/defaults/hot_phase.js b/x-pack/plugins/index_lifecycle_management/public/application/store/defaults/hot_phase.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/defaults/hot_phase.js
rename to x-pack/plugins/index_lifecycle_management/public/application/store/defaults/hot_phase.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/defaults/index.d.ts b/x-pack/plugins/index_lifecycle_management/public/application/store/defaults/index.d.ts
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/defaults/index.d.ts
rename to x-pack/plugins/index_lifecycle_management/public/application/store/defaults/index.d.ts
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/defaults/index.js b/x-pack/plugins/index_lifecycle_management/public/application/store/defaults/index.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/defaults/index.js
rename to x-pack/plugins/index_lifecycle_management/public/application/store/defaults/index.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/defaults/warm_phase.js b/x-pack/plugins/index_lifecycle_management/public/application/store/defaults/warm_phase.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/defaults/warm_phase.js
rename to x-pack/plugins/index_lifecycle_management/public/application/store/defaults/warm_phase.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/index.d.ts b/x-pack/plugins/index_lifecycle_management/public/application/store/index.d.ts
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/index.d.ts
rename to x-pack/plugins/index_lifecycle_management/public/application/store/index.d.ts
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/index.js b/x-pack/plugins/index_lifecycle_management/public/application/store/index.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/index.js
rename to x-pack/plugins/index_lifecycle_management/public/application/store/index.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/reducers/general.js b/x-pack/plugins/index_lifecycle_management/public/application/store/reducers/general.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/reducers/general.js
rename to x-pack/plugins/index_lifecycle_management/public/application/store/reducers/general.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/reducers/index.js b/x-pack/plugins/index_lifecycle_management/public/application/store/reducers/index.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/reducers/index.js
rename to x-pack/plugins/index_lifecycle_management/public/application/store/reducers/index.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/reducers/nodes.js b/x-pack/plugins/index_lifecycle_management/public/application/store/reducers/nodes.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/reducers/nodes.js
rename to x-pack/plugins/index_lifecycle_management/public/application/store/reducers/nodes.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/reducers/policies.js b/x-pack/plugins/index_lifecycle_management/public/application/store/reducers/policies.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/reducers/policies.js
rename to x-pack/plugins/index_lifecycle_management/public/application/store/reducers/policies.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/selectors/general.js b/x-pack/plugins/index_lifecycle_management/public/application/store/selectors/general.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/selectors/general.js
rename to x-pack/plugins/index_lifecycle_management/public/application/store/selectors/general.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/selectors/index.js b/x-pack/plugins/index_lifecycle_management/public/application/store/selectors/index.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/selectors/index.js
rename to x-pack/plugins/index_lifecycle_management/public/application/store/selectors/index.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/selectors/lifecycle.js b/x-pack/plugins/index_lifecycle_management/public/application/store/selectors/lifecycle.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/selectors/lifecycle.js
rename to x-pack/plugins/index_lifecycle_management/public/application/store/selectors/lifecycle.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/selectors/nodes.js b/x-pack/plugins/index_lifecycle_management/public/application/store/selectors/nodes.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/selectors/nodes.js
rename to x-pack/plugins/index_lifecycle_management/public/application/store/selectors/nodes.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/selectors/policies.js b/x-pack/plugins/index_lifecycle_management/public/application/store/selectors/policies.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/selectors/policies.js
rename to x-pack/plugins/index_lifecycle_management/public/application/store/selectors/policies.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/store.js b/x-pack/plugins/index_lifecycle_management/public/application/store/store.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/application/store/store.js
rename to x-pack/plugins/index_lifecycle_management/public/application/store/store.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/extend_index_management/components/add_lifecycle_confirm_modal.js b/x-pack/plugins/index_lifecycle_management/public/extend_index_management/components/add_lifecycle_confirm_modal.js
similarity index 97%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/extend_index_management/components/add_lifecycle_confirm_modal.js
rename to x-pack/plugins/index_lifecycle_management/public/extend_index_management/components/add_lifecycle_confirm_modal.js
index 5b8f2d197daf4..143895150172d 100644
--- a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/extend_index_management/components/add_lifecycle_confirm_modal.js
+++ b/x-pack/plugins/index_lifecycle_management/public/extend_index_management/components/add_lifecycle_confirm_modal.js
@@ -23,7 +23,7 @@ import {
EuiModalHeaderTitle,
} from '@elastic/eui';
-import { BASE_PATH } from '../../../../common/constants';
+import { BASE_PATH } from '../../../common/constants';
import { loadPolicies, addLifecyclePolicyToIndex } from '../../application/services/api';
import { showApiError } from '../../application/services/api_errors';
import { toasts } from '../../application/services/notification';
@@ -38,7 +38,7 @@ export class AddLifecyclePolicyConfirmModal extends Component {
};
}
addPolicy = async () => {
- const { indexName, httpClient, closeModal, reloadIndices } = this.props;
+ const { indexName, closeModal, reloadIndices } = this.props;
const { selectedPolicyName, selectedAlias } = this.state;
if (!selectedPolicyName) {
this.setState({
@@ -55,7 +55,7 @@ export class AddLifecyclePolicyConfirmModal extends Component {
policyName: selectedPolicyName,
alias: selectedAlias,
};
- await addLifecyclePolicyToIndex(body, httpClient);
+ await addLifecyclePolicyToIndex(body);
closeModal();
toasts.addSuccess(
i18n.translate(
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/extend_index_management/components/index_lifecycle_summary.js b/x-pack/plugins/index_lifecycle_management/public/extend_index_management/components/index_lifecycle_summary.js
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/extend_index_management/components/index_lifecycle_summary.js
rename to x-pack/plugins/index_lifecycle_management/public/extend_index_management/components/index_lifecycle_summary.js
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/extend_index_management/components/remove_lifecycle_confirm_modal.js b/x-pack/plugins/index_lifecycle_management/public/extend_index_management/components/remove_lifecycle_confirm_modal.js
similarity index 96%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/extend_index_management/components/remove_lifecycle_confirm_modal.js
rename to x-pack/plugins/index_lifecycle_management/public/extend_index_management/components/remove_lifecycle_confirm_modal.js
index 0ba5ed1720084..4e0d2383c7d79 100644
--- a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/extend_index_management/components/remove_lifecycle_confirm_modal.js
+++ b/x-pack/plugins/index_lifecycle_management/public/extend_index_management/components/remove_lifecycle_confirm_modal.js
@@ -24,10 +24,10 @@ export class RemoveLifecyclePolicyConfirmModal extends Component {
}
removePolicy = async () => {
- const { indexNames, httpClient, closeModal, reloadIndices } = this.props;
+ const { indexNames, closeModal, reloadIndices } = this.props;
try {
- await removeLifecycleForIndex(indexNames, httpClient);
+ await removeLifecycleForIndex(indexNames);
closeModal();
toasts.addSuccess(
i18n.translate(
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/extend_index_management/index.d.ts b/x-pack/plugins/index_lifecycle_management/public/extend_index_management/index.d.ts
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/extend_index_management/index.d.ts
rename to x-pack/plugins/index_lifecycle_management/public/extend_index_management/index.d.ts
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/extend_index_management/index.js b/x-pack/plugins/index_lifecycle_management/public/extend_index_management/index.js
similarity index 80%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/extend_index_management/index.js
rename to x-pack/plugins/index_lifecycle_management/public/extend_index_management/index.js
index 69658d31695bc..40ff04408002f 100644
--- a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/extend_index_management/index.js
+++ b/x-pack/plugins/index_lifecycle_management/public/extend_index_management/index.js
@@ -9,8 +9,6 @@ import { get, every, any } from 'lodash';
import { i18n } from '@kbn/i18n';
import { EuiSearchBar } from '@elastic/eui';
-import { init as initUiMetric } from '../application/services/ui_metric';
-import { init as initNotification } from '../application/services/notification';
import { retryLifecycleForIndex } from '../application/services/api';
import { IndexLifecycleSummary } from './components/index_lifecycle_summary';
import { AddLifecyclePolicyConfirmModal } from './components/add_lifecycle_confirm_modal';
@@ -18,21 +16,7 @@ import { RemoveLifecyclePolicyConfirmModal } from './components/remove_lifecycle
const stepPath = 'ilm.step';
-export const retryLifecycleActionExtension = ({
- indices,
- usageCollection,
- toasts,
- fatalErrors,
-}) => {
- // These are hacks that we can remove once the New Platform migration is done. They're needed here
- // because API requests and API errors require them.
- const getLegacyReporter = appName => (type, name) => {
- usageCollection.reportUiStats(appName, type, name);
- };
-
- initUiMetric(getLegacyReporter);
- initNotification(toasts, fatalErrors);
-
+export const retryLifecycleActionExtension = ({ indices }) => {
const allHaveErrors = every(indices, index => {
return index.ilm && index.ilm.failed_step;
});
@@ -57,19 +41,7 @@ export const retryLifecycleActionExtension = ({
};
};
-export const removeLifecyclePolicyActionExtension = ({
- indices,
- reloadIndices,
- createUiStatsReporter,
- toasts,
- fatalErrors,
- httpClient,
-}) => {
- // These are hacks that we can remove once the New Platform migration is done. They're needed here
- // because API requests and API errors require them.
- initUiMetric(createUiStatsReporter);
- initNotification(toasts, fatalErrors);
-
+export const removeLifecyclePolicyActionExtension = ({ indices, reloadIndices }) => {
const allHaveIlm = every(indices, index => {
return index.ilm && index.ilm.managed;
});
@@ -83,8 +55,6 @@ export const removeLifecyclePolicyActionExtension = ({
);
@@ -97,19 +67,7 @@ export const removeLifecyclePolicyActionExtension = ({
};
};
-export const addLifecyclePolicyActionExtension = ({
- indices,
- reloadIndices,
- createUiStatsReporter,
- toasts,
- fatalErrors,
- httpClient,
-}) => {
- // These are hacks that we can remove once the New Platform migration is done. They're needed here
- // because API requests and API errors require them.
- initUiMetric(createUiStatsReporter);
- initNotification(toasts, fatalErrors);
-
+export const addLifecyclePolicyActionExtension = ({ indices, reloadIndices }) => {
if (indices.length !== 1) {
return null;
}
@@ -126,8 +84,6 @@ export const addLifecyclePolicyActionExtension = ({
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/index.ts b/x-pack/plugins/index_lifecycle_management/public/index.ts
similarity index 58%
rename from x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/index.ts
rename to x-pack/plugins/index_lifecycle_management/public/index.ts
index 1af0b697a9283..586763188a54b 100644
--- a/x-pack/legacy/plugins/index_lifecycle_management/public/np_ready/index.ts
+++ b/x-pack/plugins/index_lifecycle_management/public/index.ts
@@ -4,7 +4,11 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { PluginInitializerContext } from 'src/core/public';
+import { PluginInitializerContext } from 'kibana/public';
+
import { IndexLifecycleManagementPlugin } from './plugin';
-export const createPlugin = (ctx: PluginInitializerContext) => new IndexLifecycleManagementPlugin();
+/** @public */
+export const plugin = (initializerContext: PluginInitializerContext) => {
+ return new IndexLifecycleManagementPlugin(initializerContext);
+};
diff --git a/x-pack/plugins/index_lifecycle_management/public/plugin.tsx b/x-pack/plugins/index_lifecycle_management/public/plugin.tsx
new file mode 100644
index 0000000000000..ca93646e20fcf
--- /dev/null
+++ b/x-pack/plugins/index_lifecycle_management/public/plugin.tsx
@@ -0,0 +1,69 @@
+/*
+ * 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 { CoreSetup, PluginInitializerContext } from 'src/core/public';
+
+import { PLUGIN } from '../common/constants';
+import { init as initHttp } from './application/services/http';
+import { init as initDocumentation } from './application/services/documentation';
+import { init as initUiMetric } from './application/services/ui_metric';
+import { init as initNotification } from './application/services/notification';
+import { addAllExtensions } from './extend_index_management';
+import { PluginsDependencies, ClientConfigType } from './types';
+
+export class IndexLifecycleManagementPlugin {
+ constructor(private readonly initializerContext: PluginInitializerContext) {}
+
+ public setup(coreSetup: CoreSetup, plugins: PluginsDependencies) {
+ const {
+ ui: { enabled: isIndexLifecycleManagementUiEnabled },
+ } = this.initializerContext.config.get();
+
+ if (isIndexLifecycleManagementUiEnabled) {
+ const {
+ http,
+ notifications: { toasts },
+ fatalErrors,
+ getStartServices,
+ } = coreSetup;
+
+ const { usageCollection, management, indexManagement } = plugins;
+
+ // Initialize services even if the app isn't mounted, because they're used by index management extensions.
+ initHttp(http);
+ initUiMetric(usageCollection);
+ initNotification(toasts, fatalErrors);
+
+ management.sections.getSection('elasticsearch')!.registerApp({
+ id: PLUGIN.ID,
+ title: PLUGIN.TITLE,
+ order: 2,
+ mount: async ({ element }) => {
+ const [coreStart] = await getStartServices();
+ const {
+ i18n: { Context: I18nContext },
+ docLinks: { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION },
+ } = coreStart;
+
+ // Initialize additional services.
+ initDocumentation(
+ `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference/${DOC_LINK_VERSION}/`
+ );
+
+ const { renderApp } = await import('./application');
+ return renderApp(element, I18nContext);
+ },
+ });
+
+ if (indexManagement) {
+ addAllExtensions(indexManagement.extensionsService);
+ }
+ }
+ }
+
+ public start() {}
+ public stop() {}
+}
diff --git a/x-pack/plugins/index_lifecycle_management/public/types.ts b/x-pack/plugins/index_lifecycle_management/public/types.ts
new file mode 100644
index 0000000000000..f9e0abae56cb4
--- /dev/null
+++ b/x-pack/plugins/index_lifecycle_management/public/types.ts
@@ -0,0 +1,21 @@
+/*
+ * 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 { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/public';
+import { ManagementSetup } from '../../../../src/plugins/management/public';
+import { IndexManagementPluginSetup } from '../../index_management/public';
+
+export interface PluginsDependencies {
+ usageCollection: UsageCollectionSetup;
+ management: ManagementSetup;
+ indexManagement?: IndexManagementPluginSetup;
+}
+
+export interface ClientConfigType {
+ ui: {
+ enabled: boolean;
+ };
+}
diff --git a/x-pack/plugins/index_lifecycle_management/server/config.ts b/x-pack/plugins/index_lifecycle_management/server/config.ts
new file mode 100644
index 0000000000000..9728e31a8a148
--- /dev/null
+++ b/x-pack/plugins/index_lifecycle_management/server/config.ts
@@ -0,0 +1,18 @@
+/*
+ * 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, TypeOf } from '@kbn/config-schema';
+
+export const configSchema = schema.object({
+ enabled: schema.boolean({ defaultValue: true }),
+ ui: schema.object({
+ enabled: schema.boolean({ defaultValue: true }),
+ }),
+ // Cloud requires the ability to hide internal node attributes from users.
+ filteredNodeAttributes: schema.arrayOf(schema.string(), { defaultValue: [] }),
+});
+
+export type IndexLifecycleManagementConfig = TypeOf;
diff --git a/x-pack/plugins/index_lifecycle_management/server/index.ts b/x-pack/plugins/index_lifecycle_management/server/index.ts
new file mode 100644
index 0000000000000..8a5f0fe19f9b0
--- /dev/null
+++ b/x-pack/plugins/index_lifecycle_management/server/index.ts
@@ -0,0 +1,19 @@
+/*
+ * 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 { PluginInitializerContext, PluginConfigDescriptor } from 'kibana/server';
+import { IndexLifecycleManagementServerPlugin } from './plugin';
+import { configSchema, IndexLifecycleManagementConfig } from './config';
+
+export const plugin = (ctx: PluginInitializerContext) =>
+ new IndexLifecycleManagementServerPlugin(ctx);
+
+export const config: PluginConfigDescriptor = {
+ schema: configSchema,
+ exposeToBrowser: {
+ ui: true,
+ },
+};
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/is_es_error/is_es_error.ts b/x-pack/plugins/index_lifecycle_management/server/lib/is_es_error.ts
similarity index 100%
rename from x-pack/legacy/plugins/index_lifecycle_management/server/lib/is_es_error/is_es_error.ts
rename to x-pack/plugins/index_lifecycle_management/server/lib/is_es_error.ts
diff --git a/x-pack/plugins/index_lifecycle_management/server/plugin.ts b/x-pack/plugins/index_lifecycle_management/server/plugin.ts
new file mode 100644
index 0000000000000..48c50f9a48ee5
--- /dev/null
+++ b/x-pack/plugins/index_lifecycle_management/server/plugin.ts
@@ -0,0 +1,86 @@
+/*
+ * 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 { Observable } from 'rxjs';
+import { first } from 'rxjs/operators';
+import { i18n } from '@kbn/i18n';
+import { CoreSetup, Plugin, Logger, PluginInitializerContext, APICaller } from 'src/core/server';
+
+import { PLUGIN } from '../common/constants';
+import { Dependencies } from './types';
+import { registerApiRoutes } from './routes';
+import { License } from './services';
+import { IndexLifecycleManagementConfig } from './config';
+import { isEsError } from './lib/is_es_error';
+
+const indexLifecycleDataEnricher = async (indicesList: any, callAsCurrentUser: APICaller) => {
+ if (!indicesList || !indicesList.length) {
+ return;
+ }
+
+ const params = {
+ path: '/*/_ilm/explain',
+ method: 'GET',
+ };
+
+ const { indices: ilmIndicesData } = await callAsCurrentUser('transport.request', params);
+
+ return indicesList.map((index: any): any => {
+ return {
+ ...index,
+ ilm: { ...(ilmIndicesData[index.name] || {}) },
+ };
+ });
+};
+
+export class IndexLifecycleManagementServerPlugin implements Plugin {
+ private readonly config$: Observable;
+ private readonly license: License;
+ private readonly logger: Logger;
+
+ constructor(initializerContext: PluginInitializerContext) {
+ this.logger = initializerContext.logger.get();
+ this.config$ = initializerContext.config.create();
+ this.license = new License();
+ }
+
+ async setup({ http }: CoreSetup, { licensing, indexManagement }: Dependencies): Promise {
+ const router = http.createRouter();
+ const config = await this.config$.pipe(first()).toPromise();
+
+ this.license.setup(
+ {
+ pluginId: PLUGIN.ID,
+ minimumLicenseType: PLUGIN.minimumLicenseType,
+ defaultErrorMessage: i18n.translate('xpack.indexLifecycleMgmt.licenseCheckErrorMessage', {
+ defaultMessage: 'License check failed',
+ }),
+ },
+ {
+ licensing,
+ logger: this.logger,
+ }
+ );
+
+ registerApiRoutes({
+ router,
+ config,
+ license: this.license,
+ lib: {
+ isEsError,
+ },
+ });
+
+ if (config.ui.enabled) {
+ if (indexManagement.indexDataEnricher) {
+ indexManagement.indexDataEnricher.add(indexLifecycleDataEnricher);
+ }
+ }
+ }
+
+ start() {}
+ stop() {}
+}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/index/register_index_routes.ts b/x-pack/plugins/index_lifecycle_management/server/routes/api/index/index.ts
similarity index 65%
rename from x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/index/register_index_routes.ts
rename to x-pack/plugins/index_lifecycle_management/server/routes/api/index/index.ts
index 74eb1a86a93ba..abe00af74b63a 100644
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/index/register_index_routes.ts
+++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/index/index.ts
@@ -4,12 +4,13 @@
* you may not use this file except in compliance with the Elastic License.
*/
+import { RouteDependencies } from '../../../types';
import { registerRetryRoute } from './register_retry_route';
import { registerRemoveRoute } from './register_remove_route';
import { registerAddPolicyRoute } from './register_add_policy_route';
-export function registerIndexRoutes(server: any) {
- registerRetryRoute(server);
- registerRemoveRoute(server);
- registerAddPolicyRoute(server);
+export function registerIndexRoutes(dependencies: RouteDependencies) {
+ registerRetryRoute(dependencies);
+ registerRemoveRoute(dependencies);
+ registerAddPolicyRoute(dependencies);
}
diff --git a/x-pack/plugins/index_lifecycle_management/server/routes/api/index/register_add_policy_route.ts b/x-pack/plugins/index_lifecycle_management/server/routes/api/index/register_add_policy_route.ts
new file mode 100644
index 0000000000000..9627f6399eaaf
--- /dev/null
+++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/index/register_add_policy_route.ts
@@ -0,0 +1,66 @@
+/*
+ * 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 { APICaller } from 'src/core/server';
+
+import { RouteDependencies } from '../../../types';
+import { addBasePath } from '../../../services';
+
+async function addLifecyclePolicy(
+ callAsCurrentUser: APICaller,
+ indexName: string,
+ policyName: string,
+ alias: string
+) {
+ const params = {
+ method: 'PUT',
+ path: `/${encodeURIComponent(indexName)}/_settings`,
+ body: {
+ lifecycle: {
+ name: policyName,
+ rollover_alias: alias,
+ },
+ },
+ };
+
+ return callAsCurrentUser('transport.request', params);
+}
+
+const bodySchema = schema.object({
+ indexName: schema.string(),
+ policyName: schema.string(),
+ alias: schema.maybe(schema.string()),
+});
+
+export function registerAddPolicyRoute({ router, license, lib }: RouteDependencies) {
+ router.post(
+ { path: addBasePath('/index/add'), validate: { body: bodySchema } },
+ license.guardApiRoute(async (context, request, response) => {
+ const body = request.body as typeof bodySchema.type;
+ const { indexName, policyName, alias = '' } = body;
+
+ try {
+ await addLifecyclePolicy(
+ context.core.elasticsearch.dataClient.callAsCurrentUser,
+ indexName,
+ policyName,
+ alias
+ );
+ return response.ok();
+ } catch (e) {
+ if (lib.isEsError(e)) {
+ return response.customError({
+ statusCode: e.statusCode,
+ body: e,
+ });
+ }
+ // Case: default
+ return response.internalError({ body: e });
+ }
+ })
+ );
+}
diff --git a/x-pack/plugins/index_lifecycle_management/server/routes/api/index/register_remove_route.ts b/x-pack/plugins/index_lifecycle_management/server/routes/api/index/register_remove_route.ts
new file mode 100644
index 0000000000000..8ec94a8591785
--- /dev/null
+++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/index/register_remove_route.ts
@@ -0,0 +1,54 @@
+/*
+ * 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 { APICaller } from 'src/core/server';
+
+import { RouteDependencies } from '../../../types';
+import { addBasePath } from '../../../services';
+
+async function removeLifecycle(callAsCurrentUser: APICaller, indexNames: string[]) {
+ const responses = [];
+ for (let i = 0; i < indexNames.length; i++) {
+ const indexName = indexNames[i];
+ const params = {
+ method: 'POST',
+ path: `/${encodeURIComponent(indexName)}/_ilm/remove`,
+ ignore: [404],
+ };
+
+ responses.push(callAsCurrentUser('transport.request', params));
+ }
+ return Promise.all(responses);
+}
+
+const bodySchema = schema.object({
+ indexNames: schema.arrayOf(schema.string()),
+});
+
+export function registerRemoveRoute({ router, license, lib }: RouteDependencies) {
+ router.post(
+ { path: addBasePath('/index/remove'), validate: { body: bodySchema } },
+ license.guardApiRoute(async (context, request, response) => {
+ const body = request.body as typeof bodySchema.type;
+ const { indexNames } = body;
+
+ try {
+ await removeLifecycle(context.core.elasticsearch.dataClient.callAsCurrentUser, indexNames);
+ return response.ok();
+ } catch (e) {
+ if (lib.isEsError(e)) {
+ return response.customError({
+ statusCode: e.statusCode,
+ body: e,
+ });
+ }
+ // Case: default
+ return response.internalError({ body: e });
+ }
+ })
+ );
+}
diff --git a/x-pack/plugins/index_lifecycle_management/server/routes/api/index/register_retry_route.ts b/x-pack/plugins/index_lifecycle_management/server/routes/api/index/register_retry_route.ts
new file mode 100644
index 0000000000000..1e2d621cab173
--- /dev/null
+++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/index/register_retry_route.ts
@@ -0,0 +1,54 @@
+/*
+ * 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 { APICaller } from 'src/core/server';
+
+import { RouteDependencies } from '../../../types';
+import { addBasePath } from '../../../services';
+
+async function retryLifecycle(callAsCurrentUser: APICaller, indexNames: string[]) {
+ const responses = [];
+ for (let i = 0; i < indexNames.length; i++) {
+ const indexName = indexNames[i];
+ const params = {
+ method: 'POST',
+ path: `/${encodeURIComponent(indexName)}/_ilm/retry`,
+ ignore: [404],
+ };
+
+ responses.push(callAsCurrentUser('transport.request', params));
+ }
+ return Promise.all(responses);
+}
+
+const bodySchema = schema.object({
+ indexNames: schema.arrayOf(schema.string()),
+});
+
+export function registerRetryRoute({ router, license, lib }: RouteDependencies) {
+ router.post(
+ { path: addBasePath('/index/retry'), validate: { body: bodySchema } },
+ license.guardApiRoute(async (context, request, response) => {
+ const body = request.body as typeof bodySchema.type;
+ const { indexNames } = body;
+
+ try {
+ await retryLifecycle(context.core.elasticsearch.dataClient.callAsCurrentUser, indexNames);
+ return response.ok();
+ } catch (e) {
+ if (lib.isEsError(e)) {
+ return response.customError({
+ statusCode: e.statusCode,
+ body: e,
+ });
+ }
+ // Case: default
+ return response.internalError({ body: e });
+ }
+ })
+ );
+}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/nodes/register_nodes_routes.ts b/x-pack/plugins/index_lifecycle_management/server/routes/api/nodes/index.ts
similarity index 65%
rename from x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/nodes/register_nodes_routes.ts
rename to x-pack/plugins/index_lifecycle_management/server/routes/api/nodes/index.ts
index 4486d97038657..bde56f0318bbd 100644
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/nodes/register_nodes_routes.ts
+++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/nodes/index.ts
@@ -4,10 +4,11 @@
* you may not use this file except in compliance with the Elastic License.
*/
+import { RouteDependencies } from '../../../types';
import { registerListRoute } from './register_list_route';
import { registerDetailsRoute } from './register_details_route';
-export function registerNodesRoutes(server: any) {
- registerListRoute(server);
- registerDetailsRoute(server);
+export function registerNodesRoutes(dependencies: RouteDependencies) {
+ registerListRoute(dependencies);
+ registerDetailsRoute(dependencies);
}
diff --git a/x-pack/plugins/index_lifecycle_management/server/routes/api/nodes/register_details_route.ts b/x-pack/plugins/index_lifecycle_management/server/routes/api/nodes/register_details_route.ts
new file mode 100644
index 0000000000000..6ff1f147e7ea7
--- /dev/null
+++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/nodes/register_details_route.ts
@@ -0,0 +1,64 @@
+/*
+ * 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 { APICaller } from 'src/core/server';
+
+import { RouteDependencies } from '../../../types';
+import { addBasePath } from '../../../services';
+
+function findMatchingNodes(stats: any, nodeAttrs: string): any {
+ return Object.entries(stats.nodes).reduce((accum: any[], [nodeId, nodeStats]: [any, any]) => {
+ const attributes = nodeStats.attributes || {};
+ for (const [key, value] of Object.entries(attributes)) {
+ if (`${key}:${value}` === nodeAttrs) {
+ accum.push({
+ nodeId,
+ stats: nodeStats,
+ });
+ break;
+ }
+ }
+ return accum;
+ }, []);
+}
+
+async function fetchNodeStats(callAsCurrentUser: APICaller): Promise {
+ const params = {
+ format: 'json',
+ };
+
+ return await callAsCurrentUser('nodes.stats', params);
+}
+
+const paramsSchema = schema.object({
+ nodeAttrs: schema.string(),
+});
+
+export function registerDetailsRoute({ router, license, lib }: RouteDependencies) {
+ router.get(
+ { path: addBasePath('/nodes/{nodeAttrs}/details'), validate: { params: paramsSchema } },
+ license.guardApiRoute(async (context, request, response) => {
+ const params = request.params as typeof paramsSchema.type;
+ const { nodeAttrs } = params;
+
+ try {
+ const stats = await fetchNodeStats(context.core.elasticsearch.dataClient.callAsCurrentUser);
+ const okResponse = { body: findMatchingNodes(stats, nodeAttrs) };
+ return response.ok(okResponse);
+ } catch (e) {
+ if (lib.isEsError(e)) {
+ return response.customError({
+ statusCode: e.statusCode,
+ body: e,
+ });
+ }
+ // Case: default
+ return response.internalError({ body: e });
+ }
+ })
+ );
+}
diff --git a/x-pack/plugins/index_lifecycle_management/server/routes/api/nodes/register_list_route.ts b/x-pack/plugins/index_lifecycle_management/server/routes/api/nodes/register_list_route.ts
new file mode 100644
index 0000000000000..73d85c78d3b11
--- /dev/null
+++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/nodes/register_list_route.ts
@@ -0,0 +1,69 @@
+/*
+ * 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 { APICaller } from 'src/core/server';
+
+import { RouteDependencies } from '../../../types';
+import { addBasePath } from '../../../services';
+
+function convertStatsIntoList(stats: any, disallowedNodeAttributes: string[]): any {
+ return Object.entries(stats.nodes).reduce((accum: any, [nodeId, nodeStats]: [any, any]) => {
+ const attributes = nodeStats.attributes || {};
+ for (const [key, value] of Object.entries(attributes)) {
+ const isNodeAttributeAllowed = !disallowedNodeAttributes.includes(key);
+ if (isNodeAttributeAllowed) {
+ const attributeString = `${key}:${value}`;
+ accum[attributeString] = accum[attributeString] || [];
+ accum[attributeString].push(nodeId);
+ }
+ }
+ return accum;
+ }, {});
+}
+
+async function fetchNodeStats(callAsCurrentUser: APICaller): Promise {
+ const params = {
+ format: 'json',
+ };
+
+ return await callAsCurrentUser('nodes.stats', params);
+}
+
+export function registerListRoute({ router, config, license, lib }: RouteDependencies) {
+ const { filteredNodeAttributes } = config;
+
+ const NODE_ATTRS_KEYS_TO_IGNORE: string[] = [
+ 'ml.enabled',
+ 'ml.machine_memory',
+ 'ml.max_open_jobs',
+ // Used by ML to identify nodes that have transform enabled:
+ // https://github.com/elastic/elasticsearch/pull/52712/files#diff-225cc2c1291b4c60a8c3412a619094e1R147
+ 'transform.node',
+ 'xpack.installed',
+ ];
+
+ const disallowedNodeAttributes = [...NODE_ATTRS_KEYS_TO_IGNORE, ...filteredNodeAttributes];
+
+ router.get(
+ { path: addBasePath('/nodes/list'), validate: false },
+ license.guardApiRoute(async (context, request, response) => {
+ try {
+ const stats = await fetchNodeStats(context.core.elasticsearch.dataClient.callAsCurrentUser);
+ const okResponse = { body: convertStatsIntoList(stats, disallowedNodeAttributes) };
+ return response.ok(okResponse);
+ } catch (e) {
+ if (lib.isEsError(e)) {
+ return response.customError({
+ statusCode: e.statusCode,
+ body: e,
+ });
+ }
+ // Case: default
+ return response.internalError({ body: e });
+ }
+ })
+ );
+}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/policies/register_policies_routes.ts b/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/index.ts
similarity index 64%
rename from x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/policies/register_policies_routes.ts
rename to x-pack/plugins/index_lifecycle_management/server/routes/api/policies/index.ts
index 279b016da178f..c30dc04c61169 100644
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/policies/register_policies_routes.ts
+++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/index.ts
@@ -4,12 +4,13 @@
* you may not use this file except in compliance with the Elastic License.
*/
+import { RouteDependencies } from '../../../types';
import { registerFetchRoute } from './register_fetch_route';
import { registerCreateRoute } from './register_create_route';
import { registerDeleteRoute } from './register_delete_route';
-export function registerPoliciesRoutes(server: any) {
- registerFetchRoute(server);
- registerCreateRoute(server);
- registerDeleteRoute(server);
+export function registerPoliciesRoutes(dependencies: RouteDependencies) {
+ registerFetchRoute(dependencies);
+ registerCreateRoute(dependencies);
+ registerDeleteRoute(dependencies);
}
diff --git a/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_create_route.ts b/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_create_route.ts
new file mode 100644
index 0000000000000..a9c6bab58fdd9
--- /dev/null
+++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_create_route.ts
@@ -0,0 +1,145 @@
+/*
+ * 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 { APICaller } from 'src/core/server';
+
+import { RouteDependencies } from '../../../types';
+import { addBasePath } from '../../../services';
+
+async function createPolicy(callAsCurrentUser: APICaller, name: string, phases: any): Promise {
+ const body = {
+ policy: {
+ phases,
+ },
+ };
+ const params = {
+ method: 'PUT',
+ path: `/_ilm/policy/${encodeURIComponent(name)}`,
+ ignore: [404],
+ body,
+ };
+
+ return await callAsCurrentUser('transport.request', params);
+}
+
+const minAgeSchema = schema.maybe(schema.string());
+
+const setPrioritySchema = schema.maybe(
+ schema.object({
+ priority: schema.number(),
+ })
+);
+
+const unfollowSchema = schema.maybe(schema.object({})); // Unfollow has no options
+
+const allocateNodeSchema = schema.maybe(schema.recordOf(schema.string(), schema.string()));
+const allocateSchema = schema.maybe(
+ schema.object({
+ number_of_replicas: schema.maybe(schema.number()),
+ include: allocateNodeSchema,
+ exclude: allocateNodeSchema,
+ require: allocateNodeSchema,
+ })
+);
+
+const hotPhaseSchema = schema.object({
+ min_age: minAgeSchema,
+ actions: schema.object({
+ set_priority: setPrioritySchema,
+ unfollow: unfollowSchema,
+ rollover: schema.maybe(
+ schema.object({
+ max_age: schema.maybe(schema.string()),
+ max_size: schema.maybe(schema.string()),
+ max_docs: schema.maybe(schema.number()),
+ })
+ ),
+ }),
+});
+
+const warmPhaseSchema = schema.maybe(
+ schema.object({
+ min_age: minAgeSchema,
+ actions: schema.object({
+ set_priority: setPrioritySchema,
+ unfollow: unfollowSchema,
+ read_only: schema.maybe(schema.object({})), // Readonly has no options
+ allocate: allocateSchema,
+ shrink: schema.maybe(
+ schema.object({
+ number_of_shards: schema.number(),
+ })
+ ),
+ forcemerge: schema.maybe(
+ schema.object({
+ max_num_segments: schema.number(),
+ })
+ ),
+ }),
+ })
+);
+
+const coldPhaseSchema = schema.maybe(
+ schema.object({
+ min_age: minAgeSchema,
+ actions: schema.object({
+ set_priority: setPrioritySchema,
+ unfollow: unfollowSchema,
+ allocate: allocateSchema,
+ freeze: schema.maybe(schema.object({})), // Freeze has no options
+ }),
+ })
+);
+
+const deletePhaseSchema = schema.maybe(
+ schema.object({
+ min_age: minAgeSchema,
+ actions: schema.object({
+ wait_for_snapshot: schema.maybe(
+ schema.object({
+ policy: schema.string(),
+ })
+ ),
+ delete: schema.maybe(schema.object({})), // Delete has no options
+ }),
+ })
+);
+
+// Per https://www.elastic.co/guide/en/elasticsearch/reference/current/_actions.html
+const bodySchema = schema.object({
+ name: schema.string(),
+ phases: schema.object({
+ hot: hotPhaseSchema,
+ warm: warmPhaseSchema,
+ cold: coldPhaseSchema,
+ delete: deletePhaseSchema,
+ }),
+});
+
+export function registerCreateRoute({ router, license, lib }: RouteDependencies) {
+ router.post(
+ { path: addBasePath('/policies'), validate: { body: bodySchema } },
+ license.guardApiRoute(async (context, request, response) => {
+ const body = request.body as typeof bodySchema.type;
+ const { name, phases } = body;
+
+ try {
+ await createPolicy(context.core.elasticsearch.dataClient.callAsCurrentUser, name, phases);
+ return response.ok();
+ } catch (e) {
+ if (lib.isEsError(e)) {
+ return response.customError({
+ statusCode: e.statusCode,
+ body: e,
+ });
+ }
+ // Case: default
+ return response.internalError({ body: e });
+ }
+ })
+ );
+}
diff --git a/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_delete_route.ts b/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_delete_route.ts
new file mode 100644
index 0000000000000..e08297f4d7bc4
--- /dev/null
+++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_delete_route.ts
@@ -0,0 +1,50 @@
+/*
+ * 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 { APICaller } from 'src/core/server';
+
+import { RouteDependencies } from '../../../types';
+import { addBasePath } from '../../../services';
+
+async function deletePolicies(callAsCurrentUser: APICaller, policyNames: string): Promise {
+ const params = {
+ method: 'DELETE',
+ path: `/_ilm/policy/${encodeURIComponent(policyNames)}`,
+ // we allow 404 since they may have no policies
+ ignore: [404],
+ };
+
+ return await callAsCurrentUser('transport.request', params);
+}
+
+const paramsSchema = schema.object({
+ policyNames: schema.string(),
+});
+
+export function registerDeleteRoute({ router, license, lib }: RouteDependencies) {
+ router.delete(
+ { path: addBasePath('/policies/{policyNames}'), validate: { params: paramsSchema } },
+ license.guardApiRoute(async (context, request, response) => {
+ const params = request.params as typeof paramsSchema.type;
+ const { policyNames } = params;
+
+ try {
+ await deletePolicies(context.core.elasticsearch.dataClient.callAsCurrentUser, policyNames);
+ return response.ok();
+ } catch (e) {
+ if (lib.isEsError(e)) {
+ return response.customError({
+ statusCode: e.statusCode,
+ body: e,
+ });
+ }
+ // Case: default
+ return response.internalError({ body: e });
+ }
+ })
+ );
+}
diff --git a/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_fetch_route.ts b/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_fetch_route.ts
new file mode 100644
index 0000000000000..294b7c4c65cba
--- /dev/null
+++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/policies/register_fetch_route.ts
@@ -0,0 +1,90 @@
+/*
+ * 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 { APICaller } from 'src/core/server';
+
+import { RouteDependencies } from '../../../types';
+import { addBasePath } from '../../../services';
+
+function formatPolicies(policiesMap: any): any {
+ if (policiesMap.status === 404) {
+ return [];
+ }
+
+ return Object.keys(policiesMap).reduce((accum: any[], lifecycleName: string) => {
+ const policyEntry = policiesMap[lifecycleName];
+ accum.push({
+ ...policyEntry,
+ name: lifecycleName,
+ });
+ return accum;
+ }, []);
+}
+
+async function fetchPolicies(callAsCurrentUser: APICaller): Promise {
+ const params = {
+ method: 'GET',
+ path: '/_ilm/policy',
+ // we allow 404 since they may have no policies
+ ignore: [404],
+ };
+
+ return await callAsCurrentUser('transport.request', params);
+}
+
+async function addLinkedIndices(callAsCurrentUser: APICaller, policiesMap: any) {
+ if (policiesMap.status === 404) {
+ return policiesMap;
+ }
+ const params = {
+ method: 'GET',
+ path: '/*/_ilm/explain',
+ // we allow 404 since they may have no policies
+ ignore: [404],
+ };
+
+ const policyExplanation: any = await callAsCurrentUser('transport.request', params);
+ Object.entries(policyExplanation.indices).forEach(([indexName, { policy }]: [string, any]) => {
+ if (policy && policiesMap[policy]) {
+ policiesMap[policy].linkedIndices = policiesMap[policy].linkedIndices || [];
+ policiesMap[policy].linkedIndices.push(indexName);
+ }
+ });
+}
+
+const querySchema = schema.object({
+ withIndices: schema.boolean({ defaultValue: false }),
+});
+
+export function registerFetchRoute({ router, license, lib }: RouteDependencies) {
+ router.get(
+ { path: addBasePath('/policies'), validate: { query: querySchema } },
+ license.guardApiRoute(async (context, request, response) => {
+ const query = request.query as typeof querySchema.type;
+ const { withIndices } = query;
+ const { callAsCurrentUser } = context.core.elasticsearch.dataClient;
+
+ try {
+ const policiesMap = await fetchPolicies(callAsCurrentUser);
+ if (withIndices) {
+ await addLinkedIndices(callAsCurrentUser, policiesMap);
+ }
+ const okResponse = { body: formatPolicies(policiesMap) };
+ return response.ok(okResponse);
+ } catch (e) {
+ if (lib.isEsError(e)) {
+ return response.customError({
+ statusCode: e.statusCode,
+ body: e,
+ });
+ }
+ // Case: default
+ return response.internalError({ body: e });
+ }
+ })
+ );
+}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/templates/register_templates_routes.ts b/x-pack/plugins/index_lifecycle_management/server/routes/api/templates/index.ts
similarity index 64%
rename from x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/templates/register_templates_routes.ts
rename to x-pack/plugins/index_lifecycle_management/server/routes/api/templates/index.ts
index 424b2d36b1ba2..a2d885c3170b9 100644
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/templates/register_templates_routes.ts
+++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/templates/index.ts
@@ -4,12 +4,11 @@
* you may not use this file except in compliance with the Elastic License.
*/
+import { RouteDependencies } from '../../../types';
import { registerFetchRoute } from './register_fetch_route';
-import { registerGetRoute } from './register_get_route';
import { registerAddPolicyRoute } from './register_add_policy_route';
-export function registerTemplatesRoutes(server: any) {
- registerFetchRoute(server);
- registerGetRoute(server);
- registerAddPolicyRoute(server);
+export function registerTemplatesRoutes(dependencies: RouteDependencies) {
+ registerFetchRoute(dependencies);
+ registerAddPolicyRoute(dependencies);
}
diff --git a/x-pack/plugins/index_lifecycle_management/server/routes/api/templates/register_add_policy_route.ts b/x-pack/plugins/index_lifecycle_management/server/routes/api/templates/register_add_policy_route.ts
new file mode 100644
index 0000000000000..0da8535f8d4ec
--- /dev/null
+++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/templates/register_add_policy_route.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 { merge } from 'lodash';
+import { schema } from '@kbn/config-schema';
+import { APICaller } from 'src/core/server';
+
+import { RouteDependencies } from '../../../types';
+import { addBasePath } from '../../../services';
+
+async function getIndexTemplate(callAsCurrentUser: APICaller, templateName: string): Promise {
+ const response = await callAsCurrentUser('indices.getTemplate', { name: templateName });
+ return response[templateName];
+}
+
+async function updateIndexTemplate(
+ callAsCurrentUser: APICaller,
+ templateName: string,
+ policyName: string,
+ aliasName?: string
+): Promise {
+ // Fetch existing template
+ const template = await getIndexTemplate(callAsCurrentUser, templateName);
+ merge(template, {
+ settings: {
+ index: {
+ lifecycle: {
+ name: policyName,
+ rollover_alias: aliasName,
+ },
+ },
+ },
+ });
+
+ const params = {
+ method: 'PUT',
+ path: `/_template/${encodeURIComponent(templateName)}`,
+ ignore: [404],
+ body: template,
+ };
+
+ return await callAsCurrentUser('transport.request', params);
+}
+
+const bodySchema = schema.object({
+ templateName: schema.string(),
+ policyName: schema.string(),
+ aliasName: schema.maybe(schema.string()),
+});
+
+export function registerAddPolicyRoute({ router, license, lib }: RouteDependencies) {
+ router.post(
+ { path: addBasePath('/template'), validate: { body: bodySchema } },
+ license.guardApiRoute(async (context, request, response) => {
+ const body = request.body as typeof bodySchema.type;
+ const { templateName, policyName, aliasName } = body;
+
+ try {
+ await updateIndexTemplate(
+ context.core.elasticsearch.dataClient.callAsCurrentUser,
+ templateName,
+ policyName,
+ aliasName
+ );
+ return response.ok();
+ } catch (e) {
+ if (lib.isEsError(e)) {
+ return response.customError({
+ statusCode: e.statusCode,
+ body: e,
+ });
+ }
+ // Case: default
+ return response.internalError({ body: e });
+ }
+ })
+ );
+}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/templates/register_fetch_route.ts b/x-pack/plugins/index_lifecycle_management/server/routes/api/templates/register_fetch_route.ts
similarity index 63%
rename from x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/templates/register_fetch_route.ts
rename to x-pack/plugins/index_lifecycle_management/server/routes/api/templates/register_fetch_route.ts
index fd58f471d69bb..a2dc67cb77afe 100644
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/routes/api/templates/register_fetch_route.ts
+++ b/x-pack/plugins/index_lifecycle_management/server/routes/api/templates/register_fetch_route.ts
@@ -4,10 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/
-import { callWithRequestFactory } from '../../../lib/call_with_request_factory';
-import { isEsError } from '../../../lib/is_es_error';
-import { wrapEsError, wrapUnknownError } from '../../../lib/error_wrappers';
-import { licensePreRoutingFactory } from '../../../lib/license_pre_routing_factory';
+import { APICaller } from 'src/core/server';
+
+import { RouteDependencies } from '../../../types';
+import { addBasePath } from '../../../services';
/**
* We don't want to output system template (whose name starts with a ".") which don't
@@ -49,7 +49,7 @@ function filterAndFormatTemplates(templates: any): any {
return formattedTemplates;
}
-async function fetchTemplates(callWithRequest: any): Promise {
+async function fetchTemplates(callAsCurrentUser: APICaller): Promise {
const params = {
method: 'GET',
path: '/_template',
@@ -57,30 +57,29 @@ async function fetchTemplates(callWithRequest: any): Promise {
ignore: [404],
};
- return await callWithRequest('transport.request', params);
+ return await callAsCurrentUser('transport.request', params);
}
-export function registerFetchRoute(server: any) {
- const licensePreRouting = licensePreRoutingFactory(server);
-
- server.route({
- path: '/api/index_lifecycle_management/templates',
- method: 'GET',
- handler: async (request: any) => {
- const callWithRequest = callWithRequestFactory(server, request);
+export function registerFetchRoute({ router, license, lib }: RouteDependencies) {
+ router.get(
+ { path: addBasePath('/templates'), validate: false },
+ license.guardApiRoute(async (context, request, response) => {
try {
- const templates = await fetchTemplates(callWithRequest);
- return filterAndFormatTemplates(templates);
- } catch (err) {
- if (isEsError(err)) {
- return wrapEsError(err);
+ const templates = await fetchTemplates(
+ context.core.elasticsearch.dataClient.callAsCurrentUser
+ );
+ const okResponse = { body: filterAndFormatTemplates(templates) };
+ return response.ok(okResponse);
+ } catch (e) {
+ if (lib.isEsError(e)) {
+ return response.customError({
+ statusCode: e.statusCode,
+ body: e,
+ });
}
-
- return wrapUnknownError(err);
+ // Case: default
+ return response.internalError({ body: e });
}
- },
- config: {
- pre: [licensePreRouting],
- },
- });
+ })
+ );
}
diff --git a/x-pack/plugins/index_lifecycle_management/server/routes/index.ts b/x-pack/plugins/index_lifecycle_management/server/routes/index.ts
new file mode 100644
index 0000000000000..35996721854c6
--- /dev/null
+++ b/x-pack/plugins/index_lifecycle_management/server/routes/index.ts
@@ -0,0 +1,19 @@
+/*
+ * 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 { RouteDependencies } from '../types';
+
+import { registerIndexRoutes } from './api/index';
+import { registerNodesRoutes } from './api/nodes';
+import { registerPoliciesRoutes } from './api/policies';
+import { registerTemplatesRoutes } from './api/templates';
+
+export function registerApiRoutes(dependencies: RouteDependencies) {
+ registerIndexRoutes(dependencies);
+ registerNodesRoutes(dependencies);
+ registerPoliciesRoutes(dependencies);
+ registerTemplatesRoutes(dependencies);
+}
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/check_license/index.ts b/x-pack/plugins/index_lifecycle_management/server/services/add_base_path.ts
similarity index 64%
rename from x-pack/legacy/plugins/index_lifecycle_management/server/lib/check_license/index.ts
rename to x-pack/plugins/index_lifecycle_management/server/services/add_base_path.ts
index f2c070fd44b6e..3f3dd131df7c7 100644
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/check_license/index.ts
+++ b/x-pack/plugins/index_lifecycle_management/server/services/add_base_path.ts
@@ -4,4 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/
-export { checkLicense } from './check_license';
+import { API_BASE_PATH } from '../../common/constants';
+
+export const addBasePath = (uri: string): string => `${API_BASE_PATH}${uri}`;
diff --git a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/license_pre_routing_factory/index.ts b/x-pack/plugins/index_lifecycle_management/server/services/index.ts
similarity index 74%
rename from x-pack/legacy/plugins/index_lifecycle_management/server/lib/license_pre_routing_factory/index.ts
rename to x-pack/plugins/index_lifecycle_management/server/services/index.ts
index 0743e443955f4..d7b544b290c39 100644
--- a/x-pack/legacy/plugins/index_lifecycle_management/server/lib/license_pre_routing_factory/index.ts
+++ b/x-pack/plugins/index_lifecycle_management/server/services/index.ts
@@ -4,4 +4,5 @@
* you may not use this file except in compliance with the Elastic License.
*/
-export { licensePreRoutingFactory } from './license_pre_routing_factory';
+export { License } from './license';
+export { addBasePath } from './add_base_path';
diff --git a/x-pack/plugins/index_lifecycle_management/server/services/license.ts b/x-pack/plugins/index_lifecycle_management/server/services/license.ts
new file mode 100644
index 0000000000000..31d3654c51e3e
--- /dev/null
+++ b/x-pack/plugins/index_lifecycle_management/server/services/license.ts
@@ -0,0 +1,82 @@
+/*
+ * 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 { Logger } from 'src/core/server';
+import {
+ KibanaRequest,
+ KibanaResponseFactory,
+ RequestHandler,
+ RequestHandlerContext,
+} from 'kibana/server';
+
+import { LicensingPluginSetup } from '../../../licensing/server';
+import { LicenseType } from '../../../licensing/common/types';
+
+export interface LicenseStatus {
+ isValid: boolean;
+ message?: string;
+}
+
+interface SetupSettings {
+ pluginId: string;
+ minimumLicenseType: LicenseType;
+ defaultErrorMessage: string;
+}
+
+export class License {
+ private licenseStatus: LicenseStatus = {
+ isValid: false,
+ message: 'Invalid License',
+ };
+
+ setup(
+ { pluginId, minimumLicenseType, defaultErrorMessage }: SetupSettings,
+ { licensing, logger }: { licensing: LicensingPluginSetup; logger: Logger }
+ ) {
+ licensing.license$.subscribe(license => {
+ const { state, message } = license.check(pluginId, minimumLicenseType);
+ const hasRequiredLicense = state === 'valid';
+
+ if (hasRequiredLicense) {
+ this.licenseStatus = { isValid: true };
+ } else {
+ this.licenseStatus = {
+ isValid: false,
+ message: message || defaultErrorMessage,
+ };
+ if (message) {
+ logger.info(message);
+ }
+ }
+ });
+ }
+
+ guardApiRoute(handler: RequestHandler) {
+ const license = this;
+
+ return function licenseCheck(
+ ctx: RequestHandlerContext,
+ request: KibanaRequest,
+ response: KibanaResponseFactory
+ ) {
+ const licenseStatus = license.getStatus();
+
+ if (!licenseStatus.isValid) {
+ return response.customError({
+ body: {
+ message: licenseStatus.message || '',
+ },
+ statusCode: 403,
+ });
+ }
+
+ return handler(ctx, request, response);
+ };
+ }
+
+ getStatus() {
+ return this.licenseStatus;
+ }
+}
diff --git a/x-pack/plugins/index_lifecycle_management/server/types.ts b/x-pack/plugins/index_lifecycle_management/server/types.ts
new file mode 100644
index 0000000000000..7f64c1a47197a
--- /dev/null
+++ b/x-pack/plugins/index_lifecycle_management/server/types.ts
@@ -0,0 +1,27 @@
+/*
+ * 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 { IRouter } from 'src/core/server';
+
+import { LicensingPluginSetup } from '../../licensing/server';
+import { IndexManagementPluginSetup } from '../../index_management/server';
+import { License } from './services';
+import { IndexLifecycleManagementConfig } from './config';
+import { isEsError } from './lib/is_es_error';
+
+export interface Dependencies {
+ licensing: LicensingPluginSetup;
+ indexManagement: IndexManagementPluginSetup;
+}
+
+export interface RouteDependencies {
+ router: IRouter;
+ config: IndexLifecycleManagementConfig;
+ license: License;
+ lib: {
+ isEsError: typeof isEsError;
+ };
+}
diff --git a/x-pack/plugins/index_management/public/application/sections/home/index_list/index_actions_context_menu/index_actions_context_menu.js b/x-pack/plugins/index_management/public/application/sections/home/index_list/index_actions_context_menu/index_actions_context_menu.js
index 8f794ce1ed612..a351d39b123a8 100644
--- a/x-pack/plugins/index_management/public/application/sections/home/index_list/index_actions_context_menu/index_actions_context_menu.js
+++ b/x-pack/plugins/index_management/public/application/sections/home/index_list/index_actions_context_menu/index_actions_context_menu.js
@@ -46,11 +46,7 @@ export class IndexActionsContextMenu extends Component {
confirmAction = isActionConfirmed => {
this.setState({ isActionConfirmed });
};
- panels({
- core: { fatalErrors },
- services: { extensionsService, httpService, notificationService },
- plugins: { usageCollection },
- }) {
+ panels({ services: { extensionsService } }) {
const {
closeIndices,
openIndices,
@@ -218,15 +214,6 @@ export class IndexActionsContextMenu extends Component {
const actionExtensionDefinition = actionExtension({
indices,
reloadIndices,
- // These config options can be removed once the NP migration out of legacy is complete.
- // They're needed for now because ILM's extensions make API calls which require these
- // dependencies, but they're not available unless the app's "setup" lifecycle stage occurs.
- // Within the old platform, "setup" only occurs once the user actually visits the app.
- // Once ILM and IM have been moved out of legacy this hack won't be necessary.
- usageCollection,
- toasts: notificationService.toasts,
- fatalErrors,
- httpClient: httpService.httpClient,
});
if (actionExtensionDefinition) {
const {
diff --git a/x-pack/plugins/index_management/public/index.ts b/x-pack/plugins/index_management/public/index.ts
index 6bb921ef648f3..7a76fff7f3ec6 100644
--- a/x-pack/plugins/index_management/public/index.ts
+++ b/x-pack/plugins/index_management/public/index.ts
@@ -4,13 +4,13 @@
* you may not use this file except in compliance with the Elastic License.
*/
import './index.scss';
-import { IndexMgmtUIPlugin, IndexMgmtSetup } from './plugin';
+import { IndexMgmtUIPlugin, IndexManagementPluginSetup } from './plugin';
/** @public */
export const plugin = () => {
return new IndexMgmtUIPlugin();
};
-export { IndexMgmtSetup };
+export { IndexManagementPluginSetup };
export { getIndexListUri } from './application/services/navigation';
diff --git a/x-pack/plugins/index_management/public/plugin.ts b/x-pack/plugins/index_management/public/plugin.ts
index 4aa06d286e3c4..f9e2a47170b3d 100644
--- a/x-pack/plugins/index_management/public/plugin.ts
+++ b/x-pack/plugins/index_management/public/plugin.ts
@@ -20,7 +20,7 @@ import { setUiMetricService } from './application/services/api';
import { IndexMgmtMetricsType } from './types';
import { ExtensionsService, ExtensionsSetup } from './services';
-export interface IndexMgmtSetup {
+export interface IndexManagementPluginSetup {
extensionsService: ExtensionsSetup;
}
@@ -40,7 +40,7 @@ export class IndexMgmtUIPlugin {
setUiMetricService(this.uiMetricService);
}
- public setup(coreSetup: CoreSetup, plugins: PluginsDependencies): IndexMgmtSetup {
+ public setup(coreSetup: CoreSetup, plugins: PluginsDependencies): IndexManagementPluginSetup {
const { http, notifications } = coreSetup;
const { usageCollection, management } = plugins;
diff --git a/x-pack/plugins/index_management/server/index.ts b/x-pack/plugins/index_management/server/index.ts
index e4102711708cb..4d9409e4a516c 100644
--- a/x-pack/plugins/index_management/server/index.ts
+++ b/x-pack/plugins/index_management/server/index.ts
@@ -17,6 +17,6 @@ export const config = {
/** @public */
export { Dependencies } from './types';
-export { IndexMgmtSetup } from './plugin';
+export { IndexManagementPluginSetup } from './plugin';
export { Index } from './types';
export { IndexManagementConfig } from './config';
diff --git a/x-pack/plugins/index_management/server/plugin.ts b/x-pack/plugins/index_management/server/plugin.ts
index a0a9151cdb71f..e5bd7451b028f 100644
--- a/x-pack/plugins/index_management/server/plugin.ts
+++ b/x-pack/plugins/index_management/server/plugin.ts
@@ -12,13 +12,13 @@ import { ApiRoutes } from './routes';
import { License, IndexDataEnricher } from './services';
import { isEsError } from './lib/is_es_error';
-export interface IndexMgmtSetup {
+export interface IndexManagementPluginSetup {
indexDataEnricher: {
add: IndexDataEnricher['add'];
};
}
-export class IndexMgmtServerPlugin implements Plugin {
+export class IndexMgmtServerPlugin implements Plugin {
private readonly apiRoutes: ApiRoutes;
private readonly license: License;
private readonly logger: Logger;
@@ -31,7 +31,7 @@ export class IndexMgmtServerPlugin implements Plugin {
const loadTemplates = () => supertest.get(`${API_BASE_PATH}/templates`);
- const getTemplate = name => supertest.get(`${API_BASE_PATH}/templates/${name}`);
-
const addPolicyToTemplate = (templateName, policyName, aliasName) =>
supertest
.post(`${API_BASE_PATH}/template`)
@@ -23,7 +21,6 @@ export const registerHelpers = ({ supertest }) => {
return {
loadTemplates,
- getTemplate,
addPolicyToTemplate,
};
};
diff --git a/x-pack/test/api_integration/apis/management/index_lifecycle_management/templates.js b/x-pack/test/api_integration/apis/management/index_lifecycle_management/templates.js
index 374577825cd94..d30c20527471b 100644
--- a/x-pack/test/api_integration/apis/management/index_lifecycle_management/templates.js
+++ b/x-pack/test/api_integration/apis/management/index_lifecycle_management/templates.js
@@ -16,7 +16,7 @@ export default function({ getService }) {
const { createIndexTemplate, cleanUp: cleanUpEsResources } = initElasticsearchHelpers(es);
- const { loadTemplates, getTemplate, addPolicyToTemplate } = registerTemplatesHelpers({
+ const { loadTemplates, addPolicyToTemplate } = registerTemplatesHelpers({
supertest,
});
@@ -48,18 +48,6 @@ export default function({ getService }) {
});
});
- describe('get', () => {
- it('should fetch a single template', async () => {
- // Create a template with the ES client
- const templateName = getRandomString();
- const template = getTemplatePayload();
- await createIndexTemplate(templateName, template);
-
- const { body } = await getTemplate(templateName).expect(200);
- expect(body.index_patterns).to.eql(template.index_patterns);
- });
- });
-
describe('update', () => {
it('should add a policy to a template', async () => {
// Create policy
@@ -78,12 +66,13 @@ export default function({ getService }) {
await addPolicyToTemplate(templateName, policyName, rolloverAlias).expect(200);
// Fetch the template and verify that the policy has been attached
- const { body } = await getTemplate(templateName);
+ const { body } = await loadTemplates();
+ const fetchedTemplate = body.find(({ name }) => templateName === name);
const {
settings: {
index: { lifecycle },
},
- } = body;
+ } = fetchedTemplate;
expect(lifecycle.name).to.equal(policyName);
expect(lifecycle.rollover_alias).to.equal(rolloverAlias);
});