diff --git a/x-pack/plugins/index_management/common/constants/api_base_path.ts b/x-pack/plugins/index_management/common/constants/api_base_path.ts index c923913bb9d83..c111d95dab192 100644 --- a/x-pack/plugins/index_management/common/constants/api_base_path.ts +++ b/x-pack/plugins/index_management/common/constants/api_base_path.ts @@ -6,3 +6,5 @@ */ export const API_BASE_PATH = '/api/index_management'; + +export const INTERNAL_API_BASE_PATH = '/internal/index_management'; diff --git a/x-pack/plugins/index_management/common/constants/index.ts b/x-pack/plugins/index_management/common/constants/index.ts index 6641e6ef67c7d..786dad4a5e375 100644 --- a/x-pack/plugins/index_management/common/constants/index.ts +++ b/x-pack/plugins/index_management/common/constants/index.ts @@ -6,7 +6,7 @@ */ export { BASE_PATH } from './base_path'; -export { API_BASE_PATH } from './api_base_path'; +export { API_BASE_PATH, INTERNAL_API_BASE_PATH } from './api_base_path'; export { INVALID_INDEX_PATTERN_CHARS, INVALID_TEMPLATE_NAME_CHARS } from './invalid_characters'; export * from './index_statuses'; diff --git a/x-pack/plugins/index_management/common/index.ts b/x-pack/plugins/index_management/common/index.ts index 127123609b186..a481d17615d8d 100644 --- a/x-pack/plugins/index_management/common/index.ts +++ b/x-pack/plugins/index_management/common/index.ts @@ -8,7 +8,7 @@ // TODO: https://github.com/elastic/kibana/issues/110892 /* eslint-disable @kbn/eslint/no_export_all */ -export { API_BASE_PATH, BASE_PATH, MAJOR_VERSION } from './constants'; +export { API_BASE_PATH, INTERNAL_API_BASE_PATH, BASE_PATH, MAJOR_VERSION } from './constants'; export { getTemplateParameter } from './lib'; diff --git a/x-pack/plugins/index_management/public/services/public_api_service.ts b/x-pack/plugins/index_management/public/services/public_api_service.ts index 47485d2f7e548..33d43b9304fdb 100644 --- a/x-pack/plugins/index_management/public/services/public_api_service.ts +++ b/x-pack/plugins/index_management/public/services/public_api_service.ts @@ -6,11 +6,12 @@ */ import { HttpSetup } from '@kbn/core/public'; -import { sendRequest } from '../shared_imports'; +import { sendRequest, SendRequestResponse } from '../shared_imports'; import { API_BASE_PATH } from '../../common/constants'; +import { SerializedEnrichPolicy } from '../../common/types'; export interface PublicApiServiceSetup { - getAllEnrichPolicies(): void; + getAllEnrichPolicies(): Promise>; } /** diff --git a/x-pack/plugins/index_management/server/routes/api/enrich_policies/enrich_policies.test.ts b/x-pack/plugins/index_management/server/routes/api/enrich_policies/enrich_policies.test.ts index c61197a9996b1..57d8f3f05a3d6 100644 --- a/x-pack/plugins/index_management/server/routes/api/enrich_policies/enrich_policies.test.ts +++ b/x-pack/plugins/index_management/server/routes/api/enrich_policies/enrich_policies.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { addBasePath } from '..'; +import { addInternalBasePath } from '..'; import { RouterMock, routeDependencies, RequestMock } from '../../../test/helpers'; import { serializeEnrichmentPolicies } from '../../../lib/enrich_policies'; import { createTestESEnrichPolicy } from '../../../test/helpers'; @@ -28,13 +28,13 @@ describe('Enrich policies API', () => { jest.resetAllMocks(); }); - describe('Get all policies - GET /api/index_management/enrich_policies', () => { + describe('Get all policies - GET /internal/index_management/enrich_policies', () => { const getEnrichPolicies = router.getMockESApiFn('enrich.getPolicy'); it('returns all available policies', async () => { const mockRequest: RequestMock = { method: 'get', - path: addBasePath('/enrich_policies'), + path: addInternalBasePath('/enrich_policies'), }; getEnrichPolicies.mockResolvedValue({ policies: [mockedPolicy] }); @@ -49,7 +49,7 @@ describe('Enrich policies API', () => { it('should return an error if it fails', async () => { const mockRequest: RequestMock = { method: 'get', - path: addBasePath('/enrich_policies'), + path: addInternalBasePath('/enrich_policies'), }; const error = new Error('Oh no!'); diff --git a/x-pack/plugins/index_management/server/routes/api/enrich_policies/register_list_route.ts b/x-pack/plugins/index_management/server/routes/api/enrich_policies/register_list_route.ts index 9c76c3552ba2c..1df52d8f2ba17 100644 --- a/x-pack/plugins/index_management/server/routes/api/enrich_policies/register_list_route.ts +++ b/x-pack/plugins/index_management/server/routes/api/enrich_policies/register_list_route.ts @@ -7,12 +7,12 @@ import { IScopedClusterClient } from '@kbn/core/server'; import { RouteDependencies } from '../../../types'; -import { addBasePath } from '..'; +import { addInternalBasePath } from '..'; import { enrichPoliciesActions } from '../../../lib/enrich_policies'; export function registerListRoute({ router, lib: { handleEsError } }: RouteDependencies) { router.get( - { path: addBasePath('/enrich_policies'), validate: false }, + { path: addInternalBasePath('/enrich_policies'), validate: false }, async (context, request, response) => { const client = (await context.core).elasticsearch.client as IScopedClusterClient; try { diff --git a/x-pack/plugins/index_management/server/routes/api/index.ts b/x-pack/plugins/index_management/server/routes/api/index.ts index 98b16e21913a7..85d937717f41f 100644 --- a/x-pack/plugins/index_management/server/routes/api/index.ts +++ b/x-pack/plugins/index_management/server/routes/api/index.ts @@ -5,6 +5,8 @@ * 2.0. */ -import { API_BASE_PATH } from '../../../common'; +import { API_BASE_PATH, INTERNAL_API_BASE_PATH } from '../../../common'; export const addBasePath = (uri: string): string => API_BASE_PATH + uri; + +export const addInternalBasePath = (uri: string): string => INTERNAL_API_BASE_PATH + uri;