diff --git a/x-pack/plugins/file_upload/server/client/call_with_request_factory.js b/x-pack/plugins/file_upload/server/client/call_with_request_factory.js deleted file mode 100644 index 3ff19a5b8f84d..0000000000000 --- a/x-pack/plugins/file_upload/server/client/call_with_request_factory.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 { once } from 'lodash'; -import { getDataClient } from '../kibana_server_services'; - -const callWithRequest = once(() => getDataClient()); - -export const callWithRequestFactory = (request) => { - return (...args) => { - return ( - callWithRequest() - .asScoped(request) - // @ts-ignore - .callAsCurrentUser(...args) - ); - }; -}; diff --git a/x-pack/plugins/file_upload/server/kibana_server_services.js b/x-pack/plugins/file_upload/server/kibana_server_services.js index 880ea5caf31d3..703b55543fe07 100644 --- a/x-pack/plugins/file_upload/server/kibana_server_services.js +++ b/x-pack/plugins/file_upload/server/kibana_server_services.js @@ -4,13 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -let dataClient; - -export const setElasticsearchClientServices = (elasticsearch) => { - ({ dataClient } = elasticsearch); -}; -export const getDataClient = () => dataClient; - let internalRepository; export const setInternalRepository = (createInternalRepository) => { internalRepository = createInternalRepository(); diff --git a/x-pack/plugins/file_upload/server/plugin.js b/x-pack/plugins/file_upload/server/plugin.js index a11516d03f068..08dd8762ab49d 100644 --- a/x-pack/plugins/file_upload/server/plugin.js +++ b/x-pack/plugins/file_upload/server/plugin.js @@ -5,7 +5,7 @@ */ import { initRoutes } from './routes/file_upload'; -import { setElasticsearchClientServices, setInternalRepository } from './kibana_server_services'; +import { setInternalRepository } from './kibana_server_services'; import { registerFileUploadUsageCollector, fileUploadTelemetryMappingsType } from './telemetry'; export class FileUploadPlugin { @@ -15,7 +15,6 @@ export class FileUploadPlugin { setup(core, plugins) { core.savedObjects.registerType(fileUploadTelemetryMappingsType); - setElasticsearchClientServices(core.elasticsearch); this.router = core.http.createRouter(); registerFileUploadUsageCollector(plugins.usageCollection); } diff --git a/x-pack/plugins/file_upload/server/routes/file_upload.js b/x-pack/plugins/file_upload/server/routes/file_upload.js index cd5ccc57075a3..c7f3e2a621161 100644 --- a/x-pack/plugins/file_upload/server/routes/file_upload.js +++ b/x-pack/plugins/file_upload/server/routes/file_upload.js @@ -4,7 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -import { callWithRequestFactory } from '../client/call_with_request_factory'; import { importDataProvider } from '../models/import_data'; import { updateTelemetry } from '../telemetry/telemetry'; import { MAX_BYTES } from '../../common/constants/file_import'; @@ -86,7 +85,7 @@ const finishValidationAndProcessReq = () => { let resp; try { const validIdReqData = idConditionalValidation(body, boolHasId); - const callWithRequest = callWithRequestFactory(req); + const callWithRequest = con.core.elasticsearch.dataClient.callAsCurrentUser; const { importData: importDataFunc } = importDataProvider(callWithRequest); const { index, settings, mappings, ingestPipeline, data } = validIdReqData;