mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
Mark elasticsearch client exposed via request context as deprecated (#67319)
* add legacy prefix for es client exposed via request handler context * update src/plugins * update core mocks and tests * update test plugins * update xpack plugins * include x-pack/mocks.ts * update after master merge * update docs Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
c559eecd00
commit
4040c3090b
135 changed files with 359 additions and 332 deletions
|
@ -21,7 +21,7 @@ registerRouteHandlerContext: <T extends keyof RequestHandlerContext>(contextName
|
|||
'myApp',
|
||||
(context, req) => {
|
||||
async function search (id: string) {
|
||||
return await context.elasticsearch.adminClient.callAsInternalUser('endpoint', id);
|
||||
return await context.elasticsearch.legacy.client.callAsInternalUser('endpoint', id);
|
||||
}
|
||||
return { search };
|
||||
}
|
||||
|
|
|
@ -13,8 +13,9 @@ core: {
|
|||
typeRegistry: ISavedObjectTypeRegistry;
|
||||
};
|
||||
elasticsearch: {
|
||||
dataClient: IScopedClusterClient;
|
||||
adminClient: IScopedClusterClient;
|
||||
legacy: {
|
||||
client: IScopedClusterClient;
|
||||
};
|
||||
};
|
||||
uiSettings: {
|
||||
client: IUiSettingsClient;
|
||||
|
|
|
@ -18,5 +18,5 @@ export interface RequestHandlerContext
|
|||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [core](./kibana-plugin-core-server.requesthandlercontext.core.md) | <code>{</code><br/><code> savedObjects: {</code><br/><code> client: SavedObjectsClientContract;</code><br/><code> typeRegistry: ISavedObjectTypeRegistry;</code><br/><code> };</code><br/><code> elasticsearch: {</code><br/><code> dataClient: IScopedClusterClient;</code><br/><code> adminClient: IScopedClusterClient;</code><br/><code> };</code><br/><code> uiSettings: {</code><br/><code> client: IUiSettingsClient;</code><br/><code> };</code><br/><code> }</code> | |
|
||||
| [core](./kibana-plugin-core-server.requesthandlercontext.core.md) | <code>{</code><br/><code> savedObjects: {</code><br/><code> client: SavedObjectsClientContract;</code><br/><code> typeRegistry: ISavedObjectTypeRegistry;</code><br/><code> };</code><br/><code> elasticsearch: {</code><br/><code> legacy: {</code><br/><code> client: IScopedClusterClient;</code><br/><code> };</code><br/><code> };</code><br/><code> uiSettings: {</code><br/><code> client: IUiSettingsClient;</code><br/><code> };</code><br/><code> }</code> | |
|
||||
|
||||
|
|
|
@ -373,8 +373,7 @@ describe('http service', () => {
|
|||
const router = createRouter('/new-platform');
|
||||
router.get({ path: '/', validate: false }, async (context, req, res) => {
|
||||
// it forces client initialization since the core creates them lazily.
|
||||
await context.core.elasticsearch.adminClient.callAsCurrentUser('ping');
|
||||
await context.core.elasticsearch.dataClient.callAsCurrentUser('ping');
|
||||
await context.core.elasticsearch.legacy.client.callAsCurrentUser('ping');
|
||||
return res.ok();
|
||||
});
|
||||
|
||||
|
@ -382,11 +381,9 @@ describe('http service', () => {
|
|||
|
||||
await kbnTestServer.request.get(root, '/new-platform/').expect(200);
|
||||
|
||||
// admin client contains authHeaders for BWC with legacy platform.
|
||||
const [adminClient, dataClient] = clusterClientMock.mock.calls;
|
||||
const [, , adminClientHeaders] = adminClient;
|
||||
expect(adminClientHeaders).toEqual(authHeaders);
|
||||
const [, , dataClientHeaders] = dataClient;
|
||||
// client contains authHeaders for BWC with legacy platform.
|
||||
const [client] = clusterClientMock.mock.calls;
|
||||
const [, , dataClientHeaders] = client;
|
||||
expect(dataClientHeaders).toEqual(authHeaders);
|
||||
});
|
||||
|
||||
|
@ -398,8 +395,7 @@ describe('http service', () => {
|
|||
const router = createRouter('/new-platform');
|
||||
router.get({ path: '/', validate: false }, async (context, req, res) => {
|
||||
// it forces client initialization since the core creates them lazily.
|
||||
await context.core.elasticsearch.adminClient.callAsCurrentUser('ping');
|
||||
await context.core.elasticsearch.dataClient.callAsCurrentUser('ping');
|
||||
await context.core.elasticsearch.legacy.client.callAsCurrentUser('ping');
|
||||
return res.ok();
|
||||
});
|
||||
|
||||
|
@ -410,10 +406,8 @@ describe('http service', () => {
|
|||
.set('Authorization', authorizationHeader)
|
||||
.expect(200);
|
||||
|
||||
const [adminClient, dataClient] = clusterClientMock.mock.calls;
|
||||
const [, , adminClientHeaders] = adminClient;
|
||||
expect(adminClientHeaders).toEqual({ authorization: authorizationHeader });
|
||||
const [, , dataClientHeaders] = dataClient;
|
||||
const [client] = clusterClientMock.mock.calls;
|
||||
const [, , dataClientHeaders] = client;
|
||||
expect(dataClientHeaders).toEqual({ authorization: authorizationHeader });
|
||||
});
|
||||
});
|
||||
|
|
|
@ -234,7 +234,7 @@ export interface HttpServiceSetup {
|
|||
* 'myApp',
|
||||
* (context, req) => {
|
||||
* async function search (id: string) {
|
||||
* return await context.elasticsearch.adminClient.callAsInternalUser('endpoint', id);
|
||||
* return await context.elasticsearch.legacy.client.callAsInternalUser('endpoint', id);
|
||||
* }
|
||||
* return { search };
|
||||
* }
|
||||
|
|
|
@ -354,8 +354,9 @@ export interface RequestHandlerContext {
|
|||
typeRegistry: ISavedObjectTypeRegistry;
|
||||
};
|
||||
elasticsearch: {
|
||||
dataClient: IScopedClusterClient;
|
||||
adminClient: IScopedClusterClient;
|
||||
legacy: {
|
||||
client: IScopedClusterClient;
|
||||
};
|
||||
};
|
||||
uiSettings: {
|
||||
client: IUiSettingsClient;
|
||||
|
|
|
@ -199,8 +199,9 @@ function createCoreRequestHandlerContextMock() {
|
|||
typeRegistry: savedObjectsTypeRegistryMock.create(),
|
||||
},
|
||||
elasticsearch: {
|
||||
adminClient: elasticsearchServiceMock.createScopedClusterClient(),
|
||||
dataClient: elasticsearchServiceMock.createScopedClusterClient(),
|
||||
legacy: {
|
||||
client: elasticsearchServiceMock.createScopedClusterClient(),
|
||||
},
|
||||
},
|
||||
uiSettings: {
|
||||
client: uiSettingsServiceMock.createClient(),
|
||||
|
|
|
@ -1576,8 +1576,9 @@ export interface RequestHandlerContext {
|
|||
typeRegistry: ISavedObjectTypeRegistry;
|
||||
};
|
||||
elasticsearch: {
|
||||
dataClient: IScopedClusterClient;
|
||||
adminClient: IScopedClusterClient;
|
||||
legacy: {
|
||||
client: IScopedClusterClient;
|
||||
};
|
||||
};
|
||||
uiSettings: {
|
||||
client: IUiSettingsClient;
|
||||
|
|
|
@ -256,8 +256,9 @@ export class Server {
|
|||
typeRegistry: this.coreStart!.savedObjects.getTypeRegistry(),
|
||||
},
|
||||
elasticsearch: {
|
||||
adminClient: coreSetup.elasticsearch.adminClient.asScoped(req),
|
||||
dataClient: coreSetup.elasticsearch.dataClient.asScoped(req),
|
||||
legacy: {
|
||||
client: coreSetup.elasticsearch.dataClient.asScoped(req),
|
||||
},
|
||||
},
|
||||
uiSettings: {
|
||||
client: uiSettingsClient,
|
||||
|
|
|
@ -55,7 +55,7 @@ export function registerValueSuggestionsRoute(
|
|||
const config = await config$.pipe(first()).toPromise();
|
||||
const { field: fieldName, query, boolFilter } = request.body;
|
||||
const { index } = request.params;
|
||||
const { dataClient } = context.core.elasticsearch;
|
||||
const { client } = context.core.elasticsearch.legacy;
|
||||
const signal = getRequestAbortedSignal(request.events.aborted$);
|
||||
|
||||
const autocompleteSearchOptions = {
|
||||
|
@ -69,7 +69,7 @@ export function registerValueSuggestionsRoute(
|
|||
const body = await getBody(autocompleteSearchOptions, field || fieldName, query, boolFilter);
|
||||
|
||||
try {
|
||||
const result = await dataClient.callAsCurrentUser('search', { index, body }, { signal });
|
||||
const result = await client.callAsCurrentUser('search', { index, body }, { signal });
|
||||
|
||||
const buckets: any[] =
|
||||
get(result, 'aggregations.suggestions.buckets') ||
|
||||
|
|
|
@ -46,7 +46,7 @@ export function registerRoutes(http: HttpServiceSetup) {
|
|||
},
|
||||
},
|
||||
async (context, request, response) => {
|
||||
const { callAsCurrentUser } = context.core.elasticsearch.dataClient;
|
||||
const { callAsCurrentUser } = context.core.elasticsearch.legacy.client;
|
||||
const indexPatterns = new IndexPatternsFetcher(callAsCurrentUser);
|
||||
const { pattern, meta_fields: metaFields } = request.query;
|
||||
|
||||
|
@ -105,7 +105,7 @@ export function registerRoutes(http: HttpServiceSetup) {
|
|||
},
|
||||
},
|
||||
async (context: RequestHandlerContext, request: any, response: any) => {
|
||||
const { callAsCurrentUser } = context.core.elasticsearch.dataClient;
|
||||
const { callAsCurrentUser } = context.core.elasticsearch.legacy.client;
|
||||
const indexPatterns = new IndexPatternsFetcher(callAsCurrentUser);
|
||||
const { pattern, interval, look_back: lookBack, meta_fields: metaFields } = request.query;
|
||||
|
||||
|
|
|
@ -38,8 +38,9 @@ describe('Search service', () => {
|
|||
const mockContext = {
|
||||
core: {
|
||||
elasticsearch: {
|
||||
dataClient: {} as ScopedClusterClient,
|
||||
adminClient: {} as ScopedClusterClient,
|
||||
legacy: {
|
||||
client: {} as ScopedClusterClient,
|
||||
},
|
||||
},
|
||||
},
|
||||
search: {
|
||||
|
@ -75,8 +76,9 @@ describe('Search service', () => {
|
|||
const mockContext = {
|
||||
core: {
|
||||
elasticsearch: {
|
||||
dataClient: {} as ScopedClusterClient,
|
||||
adminClient: {} as ScopedClusterClient,
|
||||
legacy: {
|
||||
client: {} as ScopedClusterClient,
|
||||
},
|
||||
},
|
||||
},
|
||||
search: {
|
||||
|
|
|
@ -59,7 +59,7 @@ export class SearchService implements Plugin<ISearchSetup, void> {
|
|||
|
||||
core.http.registerRouteHandlerContext<'search'>('search', (context) => {
|
||||
return createApi({
|
||||
caller: context.core.elasticsearch.dataClient.callAsCurrentUser,
|
||||
caller: context.core.elasticsearch.legacy.client.callAsCurrentUser,
|
||||
searchStrategies: this.searchStrategies,
|
||||
});
|
||||
});
|
||||
|
|
|
@ -61,7 +61,7 @@ const insertDataIntoIndex = (
|
|||
bulk.push(insertCmd);
|
||||
bulk.push(updateTimestamps(doc));
|
||||
});
|
||||
const resp = await context.core.elasticsearch.adminClient.callAsCurrentUser('bulk', {
|
||||
const resp = await context.core.elasticsearch.legacy.client.callAsCurrentUser('bulk', {
|
||||
body: bulk,
|
||||
});
|
||||
if (resp.errors) {
|
||||
|
@ -110,7 +110,7 @@ export function createInstallRoute(
|
|||
|
||||
// clean up any old installation of dataset
|
||||
try {
|
||||
await context.core.elasticsearch.dataClient.callAsCurrentUser('indices.delete', {
|
||||
await context.core.elasticsearch.legacy.client.callAsCurrentUser('indices.delete', {
|
||||
index,
|
||||
});
|
||||
} catch (err) {
|
||||
|
@ -125,7 +125,7 @@ export function createInstallRoute(
|
|||
mappings: { properties: dataIndexConfig.fields },
|
||||
},
|
||||
};
|
||||
await context.core.elasticsearch.dataClient.callAsCurrentUser(
|
||||
await context.core.elasticsearch.legacy.client.callAsCurrentUser(
|
||||
'indices.create',
|
||||
createIndexParams
|
||||
);
|
||||
|
|
|
@ -47,7 +47,7 @@ export const createListRoute = (router: IRouter, sampleDatasets: SampleDatasetSc
|
|||
const dataIndexConfig = sampleDataset.dataIndices[i];
|
||||
const index = createIndexName(sampleDataset.id, dataIndexConfig.id);
|
||||
try {
|
||||
const indexExists = await context.core.elasticsearch.dataClient.callAsCurrentUser(
|
||||
const indexExists = await context.core.elasticsearch.legacy.client.callAsCurrentUser(
|
||||
'indices.exists',
|
||||
{ index }
|
||||
);
|
||||
|
@ -56,9 +56,12 @@ export const createListRoute = (router: IRouter, sampleDatasets: SampleDatasetSc
|
|||
return;
|
||||
}
|
||||
|
||||
const { count } = await context.core.elasticsearch.dataClient.callAsCurrentUser('count', {
|
||||
index,
|
||||
});
|
||||
const { count } = await context.core.elasticsearch.legacy.client.callAsCurrentUser(
|
||||
'count',
|
||||
{
|
||||
index,
|
||||
}
|
||||
);
|
||||
if (count === 0) {
|
||||
sampleDataset.status = NOT_INSTALLED;
|
||||
return;
|
||||
|
|
|
@ -39,7 +39,9 @@ export function createUninstallRoute(
|
|||
{
|
||||
core: {
|
||||
elasticsearch: {
|
||||
dataClient: { callAsCurrentUser },
|
||||
legacy: {
|
||||
client: { callAsCurrentUser },
|
||||
},
|
||||
},
|
||||
savedObjects: { client: savedObjectsClient },
|
||||
},
|
||||
|
|
|
@ -64,7 +64,7 @@ class Plugin {
|
|||
router.get(
|
||||
{ path: '/requestcontext/elasticsearch', validate: false },
|
||||
async (context, req, res) => {
|
||||
const response = await context.core.elasticsearch.adminClient.callAsInternalUser('ping');
|
||||
const response = await context.core.elasticsearch.legacy.client.callAsInternalUser('ping');
|
||||
return res.ok({ body: `Elasticsearch: ${response}` });
|
||||
}
|
||||
);
|
||||
|
@ -84,7 +84,10 @@ class Plugin {
|
|||
return `Some exposed data derived from config: ${configValue.secret}`;
|
||||
})
|
||||
),
|
||||
pingElasticsearch: () => core.elasticsearch.adminClient.callAsInternalUser('ping'),
|
||||
pingElasticsearch: async () => {
|
||||
const [coreStart] = await core.getStartServices();
|
||||
return coreStart.elasticsearch.legacy.client.callAsInternalUser('ping');
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ export function runRoute(
|
|||
allowedGraphiteUrls: configManager.getGraphiteUrls(),
|
||||
esShardTimeout: configManager.getEsShardTimeout(),
|
||||
savedObjectsClient: context.core.savedObjects.client,
|
||||
esDataClient: () => context.core.elasticsearch.dataClient,
|
||||
esDataClient: () => context.core.elasticsearch.legacy.client,
|
||||
});
|
||||
const chainRunner = chainRunnerFn(tlConfig);
|
||||
const sheet = await Bluebird.all(chainRunner.processRequest(request.body));
|
||||
|
|
|
@ -29,7 +29,7 @@ export function validateEsRoute(router: IRouter) {
|
|||
async function (context, request, response) {
|
||||
const uiSettings = await context.core.uiSettings.client.getAll();
|
||||
|
||||
const { callAsCurrentUser } = context.core.elasticsearch.dataClient;
|
||||
const { callAsCurrentUser } = context.core.elasticsearch.legacy.client;
|
||||
|
||||
const timefield = uiSettings['timelion:es.timefield'];
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ export async function getFields(
|
|||
payload: {},
|
||||
pre: {
|
||||
indexPatternsService: new IndexPatternsFetcher(
|
||||
requestContext.core.elasticsearch.dataClient.callAsCurrentUser
|
||||
requestContext.core.elasticsearch.legacy.client.callAsCurrentUser
|
||||
),
|
||||
},
|
||||
getUiSettingsService: () => requestContext.core.uiSettings.client,
|
||||
|
@ -54,7 +54,7 @@ export async function getFields(
|
|||
getCluster: () => {
|
||||
return {
|
||||
callWithRequest: async (req: any, endpoint: string, params: any) => {
|
||||
return await requestContext.core.elasticsearch.dataClient.callAsCurrentUser(
|
||||
return await requestContext.core.elasticsearch.legacy.client.callAsCurrentUser(
|
||||
endpoint,
|
||||
params
|
||||
);
|
||||
|
|
|
@ -77,7 +77,7 @@ export function getVisData(
|
|||
getCluster: () => {
|
||||
return {
|
||||
callWithRequest: async (req: any, endpoint: string, params: any) => {
|
||||
return await requestContext.core.elasticsearch.dataClient.callAsCurrentUser(
|
||||
return await requestContext.core.elasticsearch.legacy.client.callAsCurrentUser(
|
||||
endpoint,
|
||||
params
|
||||
);
|
||||
|
|
|
@ -34,7 +34,7 @@ export class CorePluginAPlugin implements Plugin {
|
|||
core.http.registerRouteHandlerContext('pluginA', (context) => {
|
||||
return {
|
||||
ping: () =>
|
||||
context.core.elasticsearch.adminClient.callAsInternalUser('ping') as Promise<string>,
|
||||
context.core.elasticsearch.legacy.client.callAsInternalUser('ping') as Promise<string>,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ export default function (kibana: any) {
|
|||
const router = http.createRouter();
|
||||
|
||||
router.get({ path: '/api/np-http-in-legacy', validate: false }, async (context, req, res) => {
|
||||
const response = await context.core.elasticsearch.adminClient.callAsInternalUser('ping');
|
||||
const response = await context.core.elasticsearch.legacy.client.callAsInternalUser('ping');
|
||||
return res.ok({ body: `Pong in legacy via new platform: ${response}` });
|
||||
});
|
||||
|
||||
|
|
18
x-pack/mocks.ts
Normal file
18
x-pack/mocks.ts
Normal file
|
@ -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 { coreMock } from '../src/core/server/mocks';
|
||||
import { licensingMock } from './plugins/licensing/server/mocks';
|
||||
|
||||
function createCoreRequestHandlerContextMock() {
|
||||
return {
|
||||
core: coreMock.createRequestHandlerContext(),
|
||||
licensing: { license: licensingMock.createLicense() },
|
||||
};
|
||||
}
|
||||
|
||||
export const xpackMocks = {
|
||||
createRequestHandlerContext: createCoreRequestHandlerContextMock,
|
||||
};
|
|
@ -83,7 +83,9 @@ describe('Actions Plugin', () => {
|
|||
client: {},
|
||||
},
|
||||
elasticsearch: {
|
||||
adminClient: jest.fn(),
|
||||
legacy: {
|
||||
client: jest.fn(),
|
||||
},
|
||||
},
|
||||
},
|
||||
} as unknown) as RequestHandlerContext,
|
||||
|
|
|
@ -334,7 +334,7 @@ export class ActionsPlugin implements Plugin<Promise<PluginSetupContract>, Plugi
|
|||
savedObjectsClient: savedObjects.getScopedClient(request, { includedHiddenTypes }),
|
||||
actionTypeRegistry: actionTypeRegistry!,
|
||||
defaultKibanaIndex,
|
||||
scopedClusterClient: context.core.elasticsearch.adminClient,
|
||||
scopedClusterClient: context.core.elasticsearch.legacy.client,
|
||||
preconfiguredActions,
|
||||
});
|
||||
},
|
||||
|
|
|
@ -20,13 +20,11 @@ export function mockHandlerArguments(
|
|||
{
|
||||
alertsClient = alertsClientMock.create(),
|
||||
listTypes: listTypesRes = [],
|
||||
elasticsearch = elasticsearchServiceMock.createSetup(),
|
||||
esClient = elasticsearchServiceMock.createClusterClient(),
|
||||
}: {
|
||||
alertsClient?: AlertsClientMock;
|
||||
listTypes?: AlertType[];
|
||||
elasticsearch?: jest.Mocked<{
|
||||
adminClient: jest.Mocked<IClusterClient>;
|
||||
}>;
|
||||
esClient?: jest.Mocked<IClusterClient>;
|
||||
},
|
||||
req: unknown,
|
||||
res?: Array<MethodKeysOf<KibanaResponseFactory>>
|
||||
|
@ -34,7 +32,7 @@ export function mockHandlerArguments(
|
|||
const listTypes = jest.fn(() => listTypesRes);
|
||||
return [
|
||||
({
|
||||
core: { elasticsearch },
|
||||
core: { elasticsearch: { legacy: { client: esClient } } },
|
||||
alerting: {
|
||||
listTypes,
|
||||
getAlertsClient() {
|
||||
|
|
|
@ -43,16 +43,16 @@ describe('healthRoute', () => {
|
|||
healthRoute(router, licenseState, encryptedSavedObjects);
|
||||
const [, handler] = router.get.mock.calls[0];
|
||||
|
||||
const elasticsearch = elasticsearchServiceMock.createSetup();
|
||||
elasticsearch.adminClient.callAsInternalUser.mockReturnValue(Promise.resolve({}));
|
||||
const esClient = elasticsearchServiceMock.createClusterClient();
|
||||
esClient.callAsInternalUser.mockReturnValue(Promise.resolve({}));
|
||||
|
||||
const [context, req, res] = mockHandlerArguments({ elasticsearch }, {}, ['ok']);
|
||||
const [context, req, res] = mockHandlerArguments({ esClient }, {}, ['ok']);
|
||||
|
||||
await handler(context, req, res);
|
||||
|
||||
expect(verifyApiAccess).toHaveBeenCalledWith(licenseState);
|
||||
|
||||
expect(elasticsearch.adminClient.callAsInternalUser.mock.calls[0]).toMatchInlineSnapshot(`
|
||||
expect(esClient.callAsInternalUser.mock.calls[0]).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
"transport.request",
|
||||
Object {
|
||||
|
@ -72,10 +72,10 @@ describe('healthRoute', () => {
|
|||
healthRoute(router, licenseState, encryptedSavedObjects);
|
||||
const [, handler] = router.get.mock.calls[0];
|
||||
|
||||
const elasticsearch = elasticsearchServiceMock.createSetup();
|
||||
elasticsearch.adminClient.callAsInternalUser.mockReturnValue(Promise.resolve({}));
|
||||
const esClient = elasticsearchServiceMock.createClusterClient();
|
||||
esClient.callAsInternalUser.mockReturnValue(Promise.resolve({}));
|
||||
|
||||
const [context, req, res] = mockHandlerArguments({ elasticsearch }, {}, ['ok']);
|
||||
const [context, req, res] = mockHandlerArguments({ esClient }, {}, ['ok']);
|
||||
|
||||
expect(await handler(context, req, res)).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
|
@ -96,10 +96,10 @@ describe('healthRoute', () => {
|
|||
healthRoute(router, licenseState, encryptedSavedObjects);
|
||||
const [, handler] = router.get.mock.calls[0];
|
||||
|
||||
const elasticsearch = elasticsearchServiceMock.createSetup();
|
||||
elasticsearch.adminClient.callAsInternalUser.mockReturnValue(Promise.resolve({}));
|
||||
const esClient = elasticsearchServiceMock.createClusterClient();
|
||||
esClient.callAsInternalUser.mockReturnValue(Promise.resolve({}));
|
||||
|
||||
const [context, req, res] = mockHandlerArguments({ elasticsearch }, {}, ['ok']);
|
||||
const [context, req, res] = mockHandlerArguments({ esClient }, {}, ['ok']);
|
||||
|
||||
expect(await handler(context, req, res)).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
|
@ -120,10 +120,10 @@ describe('healthRoute', () => {
|
|||
healthRoute(router, licenseState, encryptedSavedObjects);
|
||||
const [, handler] = router.get.mock.calls[0];
|
||||
|
||||
const elasticsearch = elasticsearchServiceMock.createSetup();
|
||||
elasticsearch.adminClient.callAsInternalUser.mockReturnValue(Promise.resolve({ security: {} }));
|
||||
const esClient = elasticsearchServiceMock.createClusterClient();
|
||||
esClient.callAsInternalUser.mockReturnValue(Promise.resolve({ security: {} }));
|
||||
|
||||
const [context, req, res] = mockHandlerArguments({ elasticsearch }, {}, ['ok']);
|
||||
const [context, req, res] = mockHandlerArguments({ esClient }, {}, ['ok']);
|
||||
|
||||
expect(await handler(context, req, res)).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
|
@ -144,12 +144,10 @@ describe('healthRoute', () => {
|
|||
healthRoute(router, licenseState, encryptedSavedObjects);
|
||||
const [, handler] = router.get.mock.calls[0];
|
||||
|
||||
const elasticsearch = elasticsearchServiceMock.createSetup();
|
||||
elasticsearch.adminClient.callAsInternalUser.mockReturnValue(
|
||||
Promise.resolve({ security: { enabled: true } })
|
||||
);
|
||||
const esClient = elasticsearchServiceMock.createClusterClient();
|
||||
esClient.callAsInternalUser.mockReturnValue(Promise.resolve({ security: { enabled: true } }));
|
||||
|
||||
const [context, req, res] = mockHandlerArguments({ elasticsearch }, {}, ['ok']);
|
||||
const [context, req, res] = mockHandlerArguments({ esClient }, {}, ['ok']);
|
||||
|
||||
expect(await handler(context, req, res)).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
|
@ -170,12 +168,12 @@ describe('healthRoute', () => {
|
|||
healthRoute(router, licenseState, encryptedSavedObjects);
|
||||
const [, handler] = router.get.mock.calls[0];
|
||||
|
||||
const elasticsearch = elasticsearchServiceMock.createSetup();
|
||||
elasticsearch.adminClient.callAsInternalUser.mockReturnValue(
|
||||
const esClient = elasticsearchServiceMock.createClusterClient();
|
||||
esClient.callAsInternalUser.mockReturnValue(
|
||||
Promise.resolve({ security: { enabled: true, ssl: {} } })
|
||||
);
|
||||
|
||||
const [context, req, res] = mockHandlerArguments({ elasticsearch }, {}, ['ok']);
|
||||
const [context, req, res] = mockHandlerArguments({ esClient }, {}, ['ok']);
|
||||
|
||||
expect(await handler(context, req, res)).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
|
@ -196,12 +194,12 @@ describe('healthRoute', () => {
|
|||
healthRoute(router, licenseState, encryptedSavedObjects);
|
||||
const [, handler] = router.get.mock.calls[0];
|
||||
|
||||
const elasticsearch = elasticsearchServiceMock.createSetup();
|
||||
elasticsearch.adminClient.callAsInternalUser.mockReturnValue(
|
||||
const esClient = elasticsearchServiceMock.createClusterClient();
|
||||
esClient.callAsInternalUser.mockReturnValue(
|
||||
Promise.resolve({ security: { enabled: true, ssl: { http: { enabled: true } } } })
|
||||
);
|
||||
|
||||
const [context, req, res] = mockHandlerArguments({ elasticsearch }, {}, ['ok']);
|
||||
const [context, req, res] = mockHandlerArguments({ esClient }, {}, ['ok']);
|
||||
|
||||
expect(await handler(context, req, res)).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
|
|
|
@ -49,7 +49,7 @@ export function healthRoute(
|
|||
enabled: isSecurityEnabled = false,
|
||||
ssl: { http: { enabled: isTLSEnabled = false } = {} } = {},
|
||||
} = {},
|
||||
}: XPackUsageSecurity = await context.core.elasticsearch.adminClient
|
||||
}: XPackUsageSecurity = await context.core.elasticsearch.legacy.client
|
||||
// `transport.request` is potentially unsafe when combined with untrusted user input.
|
||||
// Do not augment with such input.
|
||||
.callAsInternalUser('transport.request', {
|
||||
|
|
|
@ -51,7 +51,7 @@ export function createFieldsRoute(service: Service, router: IRouter, baseRoute:
|
|||
}
|
||||
|
||||
try {
|
||||
rawFields = await getRawFields(ctx.core.elasticsearch.dataClient, req.body.indexPatterns);
|
||||
rawFields = await getRawFields(ctx.core.elasticsearch.legacy.client, req.body.indexPatterns);
|
||||
} catch (err) {
|
||||
const indexPatterns = req.body.indexPatterns.join(',');
|
||||
service.logger.warn(
|
||||
|
|
|
@ -53,7 +53,7 @@ export function createIndicesRoute(service: Service, router: IRouter, baseRoute:
|
|||
|
||||
let aliases: string[] = [];
|
||||
try {
|
||||
aliases = await getAliasesFromPattern(ctx.core.elasticsearch.dataClient, pattern);
|
||||
aliases = await getAliasesFromPattern(ctx.core.elasticsearch.legacy.client, pattern);
|
||||
} catch (err) {
|
||||
service.logger.warn(
|
||||
`route ${path} error getting aliases from pattern "${pattern}": ${err.message}`
|
||||
|
@ -62,7 +62,7 @@ export function createIndicesRoute(service: Service, router: IRouter, baseRoute:
|
|||
|
||||
let indices: string[] = [];
|
||||
try {
|
||||
indices = await getIndicesFromPattern(ctx.core.elasticsearch.dataClient, pattern);
|
||||
indices = await getIndicesFromPattern(ctx.core.elasticsearch.legacy.client, pattern);
|
||||
} catch (err) {
|
||||
service.logger.warn(
|
||||
`route ${path} error getting indices from pattern "${pattern}": ${err.message}`
|
||||
|
|
|
@ -37,7 +37,7 @@ export function createTimeSeriesQueryRoute(service: Service, router: IRouter, ba
|
|||
|
||||
const result = await service.indexThreshold.timeSeriesQuery({
|
||||
logger: service.logger,
|
||||
callCluster: ctx.core.elasticsearch.dataClient.callAsCurrentUser,
|
||||
callCluster: ctx.core.elasticsearch.legacy.client.callAsCurrentUser,
|
||||
query: req.body,
|
||||
});
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ export function getESClient(
|
|||
const {
|
||||
callAsCurrentUser,
|
||||
callAsInternalUser,
|
||||
} = context.core.elasticsearch.dataClient;
|
||||
} = context.core.elasticsearch.legacy.client;
|
||||
|
||||
async function callEs(operationName: string, params: Record<string, any>) {
|
||||
const startTime = process.hrtime();
|
||||
|
|
|
@ -41,9 +41,11 @@ function getMockRequest() {
|
|||
},
|
||||
core: {
|
||||
elasticsearch: {
|
||||
dataClient: {
|
||||
callAsCurrentUser: jest.fn(),
|
||||
callAsInternalUser: jest.fn(),
|
||||
legacy: {
|
||||
client: {
|
||||
callAsCurrentUser: jest.fn(),
|
||||
callAsInternalUser: jest.fn(),
|
||||
},
|
||||
},
|
||||
},
|
||||
uiSettings: {
|
||||
|
@ -60,9 +62,11 @@ function getMockRequest() {
|
|||
} as unknown) as APMRequestHandlerContext & {
|
||||
core: {
|
||||
elasticsearch: {
|
||||
dataClient: {
|
||||
callAsCurrentUser: jest.Mock<any, any>;
|
||||
callAsInternalUser: jest.Mock<any, any>;
|
||||
legacy: {
|
||||
client: {
|
||||
callAsCurrentUser: jest.Mock<any, any>;
|
||||
callAsInternalUser: jest.Mock<any, any>;
|
||||
};
|
||||
};
|
||||
};
|
||||
uiSettings: {
|
||||
|
@ -91,7 +95,7 @@ describe('setupRequest', () => {
|
|||
const { client } = await setupRequest(mockContext, mockRequest);
|
||||
await client.search({ index: 'apm-*', body: { foo: 'bar' } } as any);
|
||||
expect(
|
||||
mockContext.core.elasticsearch.dataClient.callAsCurrentUser
|
||||
mockContext.core.elasticsearch.legacy.client.callAsCurrentUser
|
||||
).toHaveBeenCalledWith('search', {
|
||||
index: 'apm-*',
|
||||
body: {
|
||||
|
@ -114,7 +118,7 @@ describe('setupRequest', () => {
|
|||
body: { foo: 'bar' },
|
||||
} as any);
|
||||
expect(
|
||||
mockContext.core.elasticsearch.dataClient.callAsInternalUser
|
||||
mockContext.core.elasticsearch.legacy.client.callAsInternalUser
|
||||
).toHaveBeenCalledWith('search', {
|
||||
index: 'apm-*',
|
||||
body: {
|
||||
|
@ -139,7 +143,7 @@ describe('setupRequest', () => {
|
|||
body: { query: { bool: { filter: [{ term: 'someTerm' }] } } },
|
||||
});
|
||||
const params =
|
||||
mockContext.core.elasticsearch.dataClient.callAsCurrentUser.mock
|
||||
mockContext.core.elasticsearch.legacy.client.callAsCurrentUser.mock
|
||||
.calls[0][1];
|
||||
expect(params.body).toEqual({
|
||||
query: {
|
||||
|
@ -158,7 +162,7 @@ describe('setupRequest', () => {
|
|||
const { client } = await setupRequest(mockContext, mockRequest);
|
||||
await client.search({ index: 'apm-*' });
|
||||
const params =
|
||||
mockContext.core.elasticsearch.dataClient.callAsCurrentUser.mock
|
||||
mockContext.core.elasticsearch.legacy.client.callAsCurrentUser.mock
|
||||
.calls[0][1];
|
||||
expect(params.body).toEqual({
|
||||
query: {
|
||||
|
@ -182,7 +186,7 @@ describe('setupRequest', () => {
|
|||
}
|
||||
);
|
||||
const params =
|
||||
mockContext.core.elasticsearch.dataClient.callAsCurrentUser.mock
|
||||
mockContext.core.elasticsearch.legacy.client.callAsCurrentUser.mock
|
||||
.calls[0][1];
|
||||
expect(params.body).toEqual({
|
||||
query: { bool: { filter: [{ term: 'someTerm' }] } },
|
||||
|
@ -200,7 +204,7 @@ describe('setupRequest', () => {
|
|||
},
|
||||
});
|
||||
const params =
|
||||
mockContext.core.elasticsearch.dataClient.callAsCurrentUser.mock
|
||||
mockContext.core.elasticsearch.legacy.client.callAsCurrentUser.mock
|
||||
.calls[0][1];
|
||||
expect(params.body).toEqual({
|
||||
query: {
|
||||
|
@ -224,7 +228,7 @@ describe('setupRequest', () => {
|
|||
await client.search({});
|
||||
|
||||
const params =
|
||||
mockContext.core.elasticsearch.dataClient.callAsCurrentUser.mock
|
||||
mockContext.core.elasticsearch.legacy.client.callAsCurrentUser.mock
|
||||
.calls[0][1];
|
||||
expect(params.ignore_throttled).toBe(true);
|
||||
});
|
||||
|
@ -240,7 +244,7 @@ describe('setupRequest', () => {
|
|||
await client.search({});
|
||||
|
||||
const params =
|
||||
mockContext.core.elasticsearch.dataClient.callAsCurrentUser.mock
|
||||
mockContext.core.elasticsearch.legacy.client.callAsCurrentUser.mock
|
||||
.calls[0][1];
|
||||
expect(params.ignore_throttled).toBe(false);
|
||||
});
|
||||
|
|
|
@ -38,7 +38,7 @@ export const getDynamicIndexPattern = async ({
|
|||
|
||||
const indexPatternsFetcher = new IndexPatternsFetcher(
|
||||
(...rest: Parameters<APICaller>) =>
|
||||
context.core.elasticsearch.adminClient.callAsCurrentUser(...rest)
|
||||
context.core.elasticsearch.legacy.client.callAsCurrentUser(...rest)
|
||||
);
|
||||
|
||||
// Since `getDynamicIndexPattern` is called in setup_request (and thus by every endpoint)
|
||||
|
|
|
@ -104,7 +104,7 @@ export const serviceAnnotationsRoute = createRoute(() => ({
|
|||
serviceName,
|
||||
environment,
|
||||
annotationsClient,
|
||||
apiCaller: context.core.elasticsearch.dataClient.callAsCurrentUser,
|
||||
apiCaller: context.core.elasticsearch.legacy.client.callAsCurrentUser,
|
||||
});
|
||||
},
|
||||
}));
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
|
||||
const mockRouteContext = ({
|
||||
core: {
|
||||
elasticsearch: { dataClient: elasticsearchServiceMock.createScopedClusterClient() },
|
||||
elasticsearch: { legacy: { client: elasticsearchServiceMock.createScopedClusterClient() } },
|
||||
},
|
||||
} as unknown) as RequestHandlerContext;
|
||||
|
||||
|
@ -76,7 +76,7 @@ describe('Retrieve ES Fields', () => {
|
|||
},
|
||||
});
|
||||
|
||||
const callAsCurrentUserMock = mockRouteContext.core.elasticsearch.dataClient
|
||||
const callAsCurrentUserMock = mockRouteContext.core.elasticsearch.legacy.client
|
||||
.callAsCurrentUser as jest.Mock;
|
||||
|
||||
callAsCurrentUserMock.mockResolvedValueOnce(mockResults);
|
||||
|
@ -104,7 +104,7 @@ describe('Retrieve ES Fields', () => {
|
|||
},
|
||||
});
|
||||
|
||||
const callAsCurrentUserMock = mockRouteContext.core.elasticsearch.dataClient
|
||||
const callAsCurrentUserMock = mockRouteContext.core.elasticsearch.legacy.client
|
||||
.callAsCurrentUser as jest.Mock;
|
||||
|
||||
callAsCurrentUserMock.mockResolvedValueOnce(mockResults);
|
||||
|
@ -132,7 +132,7 @@ describe('Retrieve ES Fields', () => {
|
|||
},
|
||||
});
|
||||
|
||||
const callAsCurrentUserMock = mockRouteContext.core.elasticsearch.dataClient
|
||||
const callAsCurrentUserMock = mockRouteContext.core.elasticsearch.legacy.client
|
||||
.callAsCurrentUser as jest.Mock;
|
||||
|
||||
callAsCurrentUserMock.mockResolvedValueOnce(mockResults);
|
||||
|
@ -152,7 +152,7 @@ describe('Retrieve ES Fields', () => {
|
|||
},
|
||||
});
|
||||
|
||||
const callAsCurrentUserMock = mockRouteContext.core.elasticsearch.dataClient
|
||||
const callAsCurrentUserMock = mockRouteContext.core.elasticsearch.legacy.client
|
||||
.callAsCurrentUser as jest.Mock;
|
||||
|
||||
callAsCurrentUserMock.mockRejectedValueOnce(new Error('Index not found'));
|
||||
|
|
|
@ -28,7 +28,7 @@ export function initializeESFieldsRoute(deps: RouteInitializerDeps) {
|
|||
},
|
||||
},
|
||||
catchErrorHandler(async (context, request, response) => {
|
||||
const { callAsCurrentUser } = context.core.elasticsearch.dataClient;
|
||||
const { callAsCurrentUser } = context.core.elasticsearch.legacy.client;
|
||||
const { index, fields } = request.query;
|
||||
|
||||
const config = {
|
||||
|
|
|
@ -85,7 +85,7 @@ const finishValidationAndProcessReq = () => {
|
|||
let resp;
|
||||
try {
|
||||
const validIdReqData = idConditionalValidation(body, boolHasId);
|
||||
const callWithRequest = con.core.elasticsearch.dataClient.callAsCurrentUser;
|
||||
const callWithRequest = con.core.elasticsearch.legacy.client.callAsCurrentUser;
|
||||
const { importData: importDataFunc } = importDataProvider(callWithRequest);
|
||||
|
||||
const { index, settings, mappings, ingestPipeline, data } = validIdReqData;
|
||||
|
|
|
@ -32,7 +32,9 @@ export function registerExploreRoute({
|
|||
{
|
||||
core: {
|
||||
elasticsearch: {
|
||||
dataClient: { callAsCurrentUser: callCluster },
|
||||
legacy: {
|
||||
client: { callAsCurrentUser: callCluster },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -31,7 +31,9 @@ export function registerSearchRoute({
|
|||
core: {
|
||||
uiSettings: { client: uiSettings },
|
||||
elasticsearch: {
|
||||
dataClient: { callAsCurrentUser: callCluster },
|
||||
legacy: {
|
||||
client: { callAsCurrentUser: callCluster },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -100,6 +100,6 @@ export class KibanaFramework {
|
|||
options?: any
|
||||
) {
|
||||
const { elasticsearch } = requestContext.core;
|
||||
return elasticsearch.dataClient.callAsCurrentUser(endpoint, options);
|
||||
return elasticsearch.legacy.client.callAsCurrentUser(endpoint, options);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ export function registerAddPolicyRoute({ router, license, lib }: RouteDependenci
|
|||
|
||||
try {
|
||||
await addLifecyclePolicy(
|
||||
context.core.elasticsearch.dataClient.callAsCurrentUser,
|
||||
context.core.elasticsearch.legacy.client.callAsCurrentUser,
|
||||
indexName,
|
||||
policyName,
|
||||
alias
|
||||
|
|
|
@ -37,7 +37,10 @@ export function registerRemoveRoute({ router, license, lib }: RouteDependencies)
|
|||
const { indexNames } = body;
|
||||
|
||||
try {
|
||||
await removeLifecycle(context.core.elasticsearch.dataClient.callAsCurrentUser, indexNames);
|
||||
await removeLifecycle(
|
||||
context.core.elasticsearch.legacy.client.callAsCurrentUser,
|
||||
indexNames
|
||||
);
|
||||
return response.ok();
|
||||
} catch (e) {
|
||||
if (lib.isEsError(e)) {
|
||||
|
|
|
@ -37,7 +37,10 @@ export function registerRetryRoute({ router, license, lib }: RouteDependencies)
|
|||
const { indexNames } = body;
|
||||
|
||||
try {
|
||||
await retryLifecycle(context.core.elasticsearch.dataClient.callAsCurrentUser, indexNames);
|
||||
await retryLifecycle(
|
||||
context.core.elasticsearch.legacy.client.callAsCurrentUser,
|
||||
indexNames
|
||||
);
|
||||
return response.ok();
|
||||
} catch (e) {
|
||||
if (lib.isEsError(e)) {
|
||||
|
|
|
@ -46,7 +46,9 @@ export function registerDetailsRoute({ router, license, lib }: RouteDependencies
|
|||
const { nodeAttrs } = params;
|
||||
|
||||
try {
|
||||
const stats = await fetchNodeStats(context.core.elasticsearch.dataClient.callAsCurrentUser);
|
||||
const stats = await fetchNodeStats(
|
||||
context.core.elasticsearch.legacy.client.callAsCurrentUser
|
||||
);
|
||||
const okResponse = { body: findMatchingNodes(stats, nodeAttrs) };
|
||||
return response.ok(okResponse);
|
||||
} catch (e) {
|
||||
|
|
|
@ -51,7 +51,9 @@ export function registerListRoute({ router, config, license, lib }: RouteDepende
|
|||
{ path: addBasePath('/nodes/list'), validate: false },
|
||||
license.guardApiRoute(async (context, request, response) => {
|
||||
try {
|
||||
const stats = await fetchNodeStats(context.core.elasticsearch.dataClient.callAsCurrentUser);
|
||||
const stats = await fetchNodeStats(
|
||||
context.core.elasticsearch.legacy.client.callAsCurrentUser
|
||||
);
|
||||
const okResponse = { body: convertStatsIntoList(stats, disallowedNodeAttributes) };
|
||||
return response.ok(okResponse);
|
||||
} catch (e) {
|
||||
|
|
|
@ -128,7 +128,11 @@ export function registerCreateRoute({ router, license, lib }: RouteDependencies)
|
|||
const { name, phases } = body;
|
||||
|
||||
try {
|
||||
await createPolicy(context.core.elasticsearch.dataClient.callAsCurrentUser, name, phases);
|
||||
await createPolicy(
|
||||
context.core.elasticsearch.legacy.client.callAsCurrentUser,
|
||||
name,
|
||||
phases
|
||||
);
|
||||
return response.ok();
|
||||
} catch (e) {
|
||||
if (lib.isEsError(e)) {
|
||||
|
|
|
@ -33,7 +33,10 @@ export function registerDeleteRoute({ router, license, lib }: RouteDependencies)
|
|||
const { policyNames } = params;
|
||||
|
||||
try {
|
||||
await deletePolicies(context.core.elasticsearch.dataClient.callAsCurrentUser, policyNames);
|
||||
await deletePolicies(
|
||||
context.core.elasticsearch.legacy.client.callAsCurrentUser,
|
||||
policyNames
|
||||
);
|
||||
return response.ok();
|
||||
} catch (e) {
|
||||
if (lib.isEsError(e)) {
|
||||
|
|
|
@ -66,7 +66,7 @@ export function registerFetchRoute({ router, license, lib }: RouteDependencies)
|
|||
license.guardApiRoute(async (context, request, response) => {
|
||||
const query = request.query as typeof querySchema.type;
|
||||
const { withIndices } = query;
|
||||
const { callAsCurrentUser } = context.core.elasticsearch.dataClient;
|
||||
const { callAsCurrentUser } = context.core.elasticsearch.legacy.client;
|
||||
|
||||
try {
|
||||
const policiesMap = await fetchPolicies(callAsCurrentUser);
|
||||
|
|
|
@ -60,7 +60,7 @@ export function registerAddPolicyRoute({ router, license, lib }: RouteDependenci
|
|||
|
||||
try {
|
||||
await updateIndexTemplate(
|
||||
context.core.elasticsearch.dataClient.callAsCurrentUser,
|
||||
context.core.elasticsearch.legacy.client.callAsCurrentUser,
|
||||
templateName,
|
||||
policyName,
|
||||
aliasName
|
||||
|
|
|
@ -66,7 +66,7 @@ export function registerFetchRoute({ router, license, lib }: RouteDependencies)
|
|||
license.guardApiRoute(async (context, request, response) => {
|
||||
try {
|
||||
const templates = await fetchTemplates(
|
||||
context.core.elasticsearch.dataClient.callAsCurrentUser
|
||||
context.core.elasticsearch.legacy.client.callAsCurrentUser
|
||||
);
|
||||
const okResponse = { body: filterAndFormatTemplates(templates) };
|
||||
return response.ok(okResponse);
|
||||
|
|
|
@ -26,7 +26,7 @@ export function registerClearCacheRoute({ router, license, lib }: RouteDependenc
|
|||
};
|
||||
|
||||
try {
|
||||
await ctx.core.elasticsearch.dataClient.callAsCurrentUser('indices.clearCache', params);
|
||||
await ctx.core.elasticsearch.legacy.client.callAsCurrentUser('indices.clearCache', params);
|
||||
return res.ok();
|
||||
} catch (e) {
|
||||
if (lib.isEsError(e)) {
|
||||
|
|
|
@ -26,7 +26,7 @@ export function registerCloseRoute({ router, license, lib }: RouteDependencies)
|
|||
};
|
||||
|
||||
try {
|
||||
await ctx.core.elasticsearch.dataClient.callAsCurrentUser('indices.close', params);
|
||||
await ctx.core.elasticsearch.legacy.client.callAsCurrentUser('indices.close', params);
|
||||
return res.ok();
|
||||
} catch (e) {
|
||||
if (lib.isEsError(e)) {
|
||||
|
|
|
@ -27,7 +27,7 @@ export function registerDeleteRoute({ router, license, lib }: RouteDependencies)
|
|||
};
|
||||
|
||||
try {
|
||||
await ctx.core.elasticsearch.dataClient.callAsCurrentUser('indices.delete', params);
|
||||
await ctx.core.elasticsearch.legacy.client.callAsCurrentUser('indices.delete', params);
|
||||
return res.ok();
|
||||
} catch (e) {
|
||||
if (lib.isEsError(e)) {
|
||||
|
|
|
@ -27,7 +27,7 @@ export function registerFlushRoute({ router, license, lib }: RouteDependencies)
|
|||
};
|
||||
|
||||
try {
|
||||
await ctx.core.elasticsearch.dataClient.callAsCurrentUser('indices.flush', params);
|
||||
await ctx.core.elasticsearch.legacy.client.callAsCurrentUser('indices.flush', params);
|
||||
return res.ok();
|
||||
} catch (e) {
|
||||
if (lib.isEsError(e)) {
|
||||
|
|
|
@ -34,7 +34,7 @@ export function registerForcemergeRoute({ router, license, lib }: RouteDependenc
|
|||
}
|
||||
|
||||
try {
|
||||
await ctx.core.elasticsearch.dataClient.callAsCurrentUser('indices.forcemerge', params);
|
||||
await ctx.core.elasticsearch.legacy.client.callAsCurrentUser('indices.forcemerge', params);
|
||||
return res.ok();
|
||||
} catch (e) {
|
||||
if (lib.isEsError(e)) {
|
||||
|
|
|
@ -26,7 +26,7 @@ export function registerFreezeRoute({ router, license, lib }: RouteDependencies)
|
|||
};
|
||||
|
||||
try {
|
||||
await await ctx.core.elasticsearch.dataClient.callAsCurrentUser(
|
||||
await await ctx.core.elasticsearch.legacy.client.callAsCurrentUser(
|
||||
'transport.request',
|
||||
params
|
||||
);
|
||||
|
|
|
@ -14,7 +14,7 @@ export function registerListRoute({ router, license, indexDataEnricher, lib }: R
|
|||
license.guardApiRoute(async (ctx, req, res) => {
|
||||
try {
|
||||
const indices = await fetchIndices(
|
||||
ctx.core.elasticsearch.dataClient.callAsCurrentUser,
|
||||
ctx.core.elasticsearch.legacy.client.callAsCurrentUser,
|
||||
indexDataEnricher
|
||||
);
|
||||
return res.ok({ body: indices });
|
||||
|
|
|
@ -26,7 +26,7 @@ export function registerOpenRoute({ router, license, lib }: RouteDependencies) {
|
|||
};
|
||||
|
||||
try {
|
||||
await await ctx.core.elasticsearch.dataClient.callAsCurrentUser('indices.open', params);
|
||||
await await ctx.core.elasticsearch.legacy.client.callAsCurrentUser('indices.open', params);
|
||||
return res.ok();
|
||||
} catch (e) {
|
||||
if (lib.isEsError(e)) {
|
||||
|
|
|
@ -27,7 +27,7 @@ export function registerRefreshRoute({ router, license, lib }: RouteDependencies
|
|||
};
|
||||
|
||||
try {
|
||||
await ctx.core.elasticsearch.dataClient.callAsCurrentUser('indices.refresh', params);
|
||||
await ctx.core.elasticsearch.legacy.client.callAsCurrentUser('indices.refresh', params);
|
||||
return res.ok();
|
||||
} catch (e) {
|
||||
if (lib.isEsError(e)) {
|
||||
|
|
|
@ -28,7 +28,7 @@ export function registerReloadRoute({
|
|||
|
||||
try {
|
||||
const indices = await fetchIndices(
|
||||
ctx.core.elasticsearch.dataClient.callAsCurrentUser,
|
||||
ctx.core.elasticsearch.legacy.client.callAsCurrentUser,
|
||||
indexDataEnricher,
|
||||
indexNames
|
||||
);
|
||||
|
|
|
@ -24,7 +24,7 @@ export function registerUnfreezeRoute({ router, license, lib }: RouteDependencie
|
|||
};
|
||||
|
||||
try {
|
||||
await ctx.core.elasticsearch.dataClient.callAsCurrentUser('transport.request', params);
|
||||
await ctx.core.elasticsearch.legacy.client.callAsCurrentUser('transport.request', params);
|
||||
return res.ok();
|
||||
} catch (e) {
|
||||
if (lib.isEsError(e)) {
|
||||
|
|
|
@ -30,7 +30,7 @@ export function registerMappingRoute({ router, license, lib }: RouteDependencies
|
|||
};
|
||||
|
||||
try {
|
||||
const hit = await ctx.core.elasticsearch.dataClient.callAsCurrentUser(
|
||||
const hit = await ctx.core.elasticsearch.legacy.client.callAsCurrentUser(
|
||||
'indices.getMapping',
|
||||
params
|
||||
);
|
||||
|
|
|
@ -33,7 +33,7 @@ export function registerLoadRoute({ router, license, lib }: RouteDependencies) {
|
|||
};
|
||||
|
||||
try {
|
||||
const hit = await ctx.core.elasticsearch.dataClient.callAsCurrentUser(
|
||||
const hit = await ctx.core.elasticsearch.legacy.client.callAsCurrentUser(
|
||||
'indices.getSettings',
|
||||
params
|
||||
);
|
||||
|
|
|
@ -31,7 +31,7 @@ export function registerUpdateRoute({ router, license, lib }: RouteDependencies)
|
|||
};
|
||||
|
||||
try {
|
||||
const response = await ctx.core.elasticsearch.dataClient.callAsCurrentUser(
|
||||
const response = await ctx.core.elasticsearch.legacy.client.callAsCurrentUser(
|
||||
'indices.putSettings',
|
||||
params
|
||||
);
|
||||
|
|
|
@ -32,7 +32,7 @@ export function registerStatsRoute({ router, license, lib }: RouteDependencies)
|
|||
};
|
||||
|
||||
try {
|
||||
const hit = await ctx.core.elasticsearch.dataClient.callAsCurrentUser(
|
||||
const hit = await ctx.core.elasticsearch.legacy.client.callAsCurrentUser(
|
||||
'indices.stats',
|
||||
params
|
||||
);
|
||||
|
|
|
@ -18,7 +18,7 @@ export function registerCreateRoute({ router, license, lib }: RouteDependencies)
|
|||
router.put(
|
||||
{ path: addBasePath('/templates'), validate: { body: bodySchema } },
|
||||
license.guardApiRoute(async (ctx, req, res) => {
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.dataClient;
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.legacy.client;
|
||||
const template = req.body as TemplateDeserialized;
|
||||
const {
|
||||
_kbnMeta: { formatVersion },
|
||||
|
|
|
@ -41,7 +41,7 @@ export function registerDeleteRoute({ router, license }: RouteDependencies) {
|
|||
return res.badRequest({ body: 'Only index template version 1 can be deleted.' });
|
||||
}
|
||||
|
||||
await ctx.core.elasticsearch.dataClient.callAsCurrentUser('indices.deleteTemplate', {
|
||||
await ctx.core.elasticsearch.legacy.client.callAsCurrentUser('indices.deleteTemplate', {
|
||||
name,
|
||||
});
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ export function registerGetAllRoute({ router, license }: RouteDependencies) {
|
|||
router.get(
|
||||
{ path: addBasePath('/templates'), validate: false },
|
||||
license.guardApiRoute(async (ctx, req, res) => {
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.dataClient;
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.legacy.client;
|
||||
const managedTemplatePrefix = await getManagedTemplatePrefix(callAsCurrentUser);
|
||||
|
||||
const indexTemplatesByName = await callAsCurrentUser('indices.getTemplate');
|
||||
|
@ -42,7 +42,7 @@ export function registerGetOneRoute({ router, license, lib }: RouteDependencies)
|
|||
},
|
||||
license.guardApiRoute(async (ctx, req, res) => {
|
||||
const { name } = req.params as typeof paramsSchema.type;
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.dataClient;
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.legacy.client;
|
||||
|
||||
const { v: version } = req.query as TypeOf<typeof querySchema>;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ export function registerUpdateRoute({ router, license, lib }: RouteDependencies)
|
|||
validate: { body: bodySchema, params: paramsSchema },
|
||||
},
|
||||
license.guardApiRoute(async (ctx, req, res) => {
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.dataClient;
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.legacy.client;
|
||||
const { name } = req.params as typeof paramsSchema.type;
|
||||
const template = req.body as TemplateDeserialized;
|
||||
const {
|
||||
|
|
|
@ -213,7 +213,7 @@ export class KibanaFramework {
|
|||
}
|
||||
: {};
|
||||
|
||||
return elasticsearch.dataClient.callAsCurrentUser(endpoint, {
|
||||
return elasticsearch.legacy.client.callAsCurrentUser(endpoint, {
|
||||
...params,
|
||||
...frozenIndicesParams,
|
||||
});
|
||||
|
@ -223,7 +223,7 @@ export class KibanaFramework {
|
|||
return new IndexPatternsFetcher((...rest: Parameters<APICaller>) => {
|
||||
rest[1] = rest[1] || {};
|
||||
rest[1].allowNoIndices = true;
|
||||
return requestContext.core.elasticsearch.adminClient.callAsCurrentUser(...rest);
|
||||
return requestContext.core.elasticsearch.legacy.client.callAsCurrentUser(...rest);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import { getPackageSavedObjects, getKibanaSavedObject } from '../../services/epm
|
|||
const DATA_STREAM_INDEX_PATTERN = 'logs-*-*,metrics-*-*';
|
||||
|
||||
export const getListHandler: RequestHandler = async (context, request, response) => {
|
||||
const callCluster = context.core.elasticsearch.dataClient.callAsCurrentUser;
|
||||
const callCluster = context.core.elasticsearch.legacy.client.callAsCurrentUser;
|
||||
|
||||
try {
|
||||
// Get stats (size on disk) of all potentially matching indices
|
||||
|
|
|
@ -74,7 +74,7 @@ export const createDatasourceHandler: RequestHandler<
|
|||
TypeOf<typeof CreateDatasourceRequestSchema.body>
|
||||
> = async (context, request, response) => {
|
||||
const soClient = context.core.savedObjects.client;
|
||||
const callCluster = context.core.elasticsearch.adminClient.callAsCurrentUser;
|
||||
const callCluster = context.core.elasticsearch.legacy.client.callAsCurrentUser;
|
||||
const user = (await appContextService.getSecurity()?.authc.getCurrentUser(request)) || undefined;
|
||||
const newData = { ...request.body };
|
||||
try {
|
||||
|
|
|
@ -124,7 +124,7 @@ export const installPackageHandler: RequestHandler<TypeOf<
|
|||
try {
|
||||
const { pkgkey } = request.params;
|
||||
const savedObjectsClient = context.core.savedObjects.client;
|
||||
const callCluster = context.core.elasticsearch.adminClient.callAsCurrentUser;
|
||||
const callCluster = context.core.elasticsearch.legacy.client.callAsCurrentUser;
|
||||
const res = await installPackage({
|
||||
savedObjectsClient,
|
||||
pkgkey,
|
||||
|
@ -155,7 +155,7 @@ export const deletePackageHandler: RequestHandler<TypeOf<
|
|||
try {
|
||||
const { pkgkey } = request.params;
|
||||
const savedObjectsClient = context.core.savedObjects.client;
|
||||
const callCluster = context.core.elasticsearch.adminClient.callAsCurrentUser;
|
||||
const callCluster = context.core.elasticsearch.legacy.client.callAsCurrentUser;
|
||||
const res = await removeInstallation({ savedObjectsClient, pkgkey, callCluster });
|
||||
const body: DeletePackageResponse = {
|
||||
response: res,
|
||||
|
|
|
@ -55,7 +55,7 @@ export const createFleetSetupHandler: RequestHandler<
|
|||
> = async (context, request, response) => {
|
||||
try {
|
||||
const soClient = context.core.savedObjects.client;
|
||||
const callCluster = context.core.elasticsearch.adminClient.callAsCurrentUser;
|
||||
const callCluster = context.core.elasticsearch.legacy.client.callAsCurrentUser;
|
||||
await setupIngestManager(soClient, callCluster);
|
||||
await setupFleet(soClient, callCluster, {
|
||||
forceRecreate: request.body?.forceRecreate ?? false,
|
||||
|
@ -74,7 +74,7 @@ export const createFleetSetupHandler: RequestHandler<
|
|||
|
||||
export const ingestManagerSetupHandler: RequestHandler = async (context, request, response) => {
|
||||
const soClient = context.core.savedObjects.client;
|
||||
const callCluster = context.core.elasticsearch.adminClient.callAsCurrentUser;
|
||||
const callCluster = context.core.elasticsearch.legacy.client.callAsCurrentUser;
|
||||
const logger = appContextService.getLogger();
|
||||
try {
|
||||
await setupIngestManager(soClient, callCluster);
|
||||
|
|
|
@ -29,7 +29,7 @@ export const registerCreateRoute = ({
|
|||
},
|
||||
},
|
||||
license.guardApiRoute(async (ctx, req, res) => {
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.dataClient;
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.legacy.client;
|
||||
const pipeline = req.body as Pipeline;
|
||||
|
||||
const { name, description, processors, version, on_failure } = pipeline;
|
||||
|
|
|
@ -21,7 +21,7 @@ export const registerDeleteRoute = ({ router, license }: RouteDependencies): voi
|
|||
},
|
||||
},
|
||||
license.guardApiRoute(async (ctx, req, res) => {
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.dataClient;
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.legacy.client;
|
||||
const { names } = req.params;
|
||||
const pipelineNames = names.split(',');
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ export const registerGetRoutes = ({
|
|||
router.get(
|
||||
{ path: API_BASE_PATH, validate: false },
|
||||
license.guardApiRoute(async (ctx, req, res) => {
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.dataClient;
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.legacy.client;
|
||||
|
||||
try {
|
||||
const pipelines = await callAsCurrentUser('ingest.getPipeline');
|
||||
|
@ -56,7 +56,7 @@ export const registerGetRoutes = ({
|
|||
},
|
||||
},
|
||||
license.guardApiRoute(async (ctx, req, res) => {
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.dataClient;
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.legacy.client;
|
||||
const { name } = req.params;
|
||||
|
||||
try {
|
||||
|
|
|
@ -36,12 +36,14 @@ export const registerPrivilegesRoute = ({ license, router, config }: RouteDepend
|
|||
|
||||
const {
|
||||
core: {
|
||||
elasticsearch: { dataClient },
|
||||
elasticsearch: {
|
||||
legacy: { client },
|
||||
},
|
||||
},
|
||||
} = ctx;
|
||||
|
||||
try {
|
||||
const { has_all_requested: hasAllPrivileges, cluster } = await dataClient.callAsCurrentUser(
|
||||
const { has_all_requested: hasAllPrivileges, cluster } = await client.callAsCurrentUser(
|
||||
'transport.request',
|
||||
{
|
||||
path: '/_security/user/_has_privileges',
|
||||
|
|
|
@ -28,7 +28,7 @@ export const registerSimulateRoute = ({
|
|||
},
|
||||
},
|
||||
license.guardApiRoute(async (ctx, req, res) => {
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.dataClient;
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.legacy.client;
|
||||
|
||||
const { pipeline, documents, verbose } = req.body;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ export const registerUpdateRoute = ({
|
|||
},
|
||||
},
|
||||
license.guardApiRoute(async (ctx, req, res) => {
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.dataClient;
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.legacy.client;
|
||||
const { name } = req.params;
|
||||
const { description, processors, version, on_failure } = req.body;
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ async function fetchFieldExistence({
|
|||
fromDate,
|
||||
toDate,
|
||||
dslQuery,
|
||||
client: context.core.elasticsearch.dataClient,
|
||||
client: context.core.elasticsearch.legacy.client,
|
||||
index: indexPatternTitle,
|
||||
timeFieldName: timeFieldName || indexPattern.attributes.timeFieldName,
|
||||
fields,
|
||||
|
@ -131,7 +131,7 @@ async function fetchFieldExistence({
|
|||
|
||||
async function fetchIndexPatternDefinition(indexPatternId: string, context: RequestHandlerContext) {
|
||||
const savedObjectsClient = context.core.savedObjects.client;
|
||||
const requestClient = context.core.elasticsearch.dataClient;
|
||||
const requestClient = context.core.elasticsearch.legacy.client;
|
||||
const indexPattern = await savedObjectsClient.get<IndexPatternAttributes>(
|
||||
'index-pattern',
|
||||
indexPatternId
|
||||
|
|
|
@ -42,7 +42,7 @@ export async function initFieldsRoute(setup: CoreSetup) {
|
|||
},
|
||||
},
|
||||
async (context, req, res) => {
|
||||
const requestClient = context.core.elasticsearch.dataClient;
|
||||
const requestClient = context.core.elasticsearch.legacy.client;
|
||||
const { fromDate, toDate, timeFieldName, field, dslQuery } = req.body;
|
||||
|
||||
try {
|
||||
|
|
|
@ -21,7 +21,7 @@ export function registerLicenseRoute({ router, plugins: { licensing } }: RouteDe
|
|||
},
|
||||
},
|
||||
async (ctx, req, res) => {
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.adminClient;
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.legacy.client;
|
||||
try {
|
||||
return res.ok({
|
||||
body: await putLicense({
|
||||
|
|
|
@ -13,7 +13,7 @@ export function registerPermissionsRoute({
|
|||
config: { isSecurityEnabled },
|
||||
}: RouteDependencies) {
|
||||
router.post({ path: addBasePath('/permissions'), validate: false }, async (ctx, req, res) => {
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.adminClient;
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.legacy.client;
|
||||
|
||||
try {
|
||||
return res.ok({
|
||||
|
|
|
@ -16,7 +16,7 @@ export function registerStartBasicRoute({ router, plugins: { licensing } }: Rout
|
|||
validate: { query: schema.object({ acknowledge: schema.string() }) },
|
||||
},
|
||||
async (ctx, req, res) => {
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.adminClient;
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.legacy.client;
|
||||
try {
|
||||
return res.ok({
|
||||
body: await startBasic({
|
||||
|
|
|
@ -10,7 +10,7 @@ import { addBasePath } from '../../helpers';
|
|||
|
||||
export function registerStartTrialRoutes({ router, plugins: { licensing } }: RouteDependencies) {
|
||||
router.get({ path: addBasePath('/start_trial'), validate: false }, async (ctx, req, res) => {
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.adminClient;
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.legacy.client;
|
||||
try {
|
||||
return res.ok({ body: await canStartTrial(callAsCurrentUser) });
|
||||
} catch (e) {
|
||||
|
@ -19,7 +19,7 @@ export function registerStartTrialRoutes({ router, plugins: { licensing } }: Rou
|
|||
});
|
||||
|
||||
router.post({ path: addBasePath('/start_trial'), validate: false }, async (ctx, req, res) => {
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.adminClient;
|
||||
const { callAsCurrentUser } = ctx.core.elasticsearch.legacy.client;
|
||||
try {
|
||||
return res.ok({
|
||||
body: await startTrial({ callAsCurrentUser, licensing }),
|
||||
|
|
|
@ -87,7 +87,9 @@ export class ListPlugin
|
|||
core: {
|
||||
savedObjects: { client: savedObjectsClient },
|
||||
elasticsearch: {
|
||||
dataClient: { callAsCurrentUser: callCluster },
|
||||
legacy: {
|
||||
client: { callAsCurrentUser: callCluster },
|
||||
},
|
||||
},
|
||||
},
|
||||
} = context;
|
||||
|
|
|
@ -502,7 +502,7 @@ export function initRoutes(router, licenseUid, mapConfig, kbnVersion, logger) {
|
|||
}
|
||||
|
||||
try {
|
||||
const resp = await con.core.elasticsearch.dataClient.callAsCurrentUser(
|
||||
const resp = await con.core.elasticsearch.legacy.client.callAsCurrentUser(
|
||||
'indices.getSettings',
|
||||
{
|
||||
index: query.indexPatternTitle,
|
||||
|
|
|
@ -66,7 +66,7 @@ export function jobValidationRoutes({ router, mlLicense }: RouteInitialization,
|
|||
let errorResp;
|
||||
const resp = await estimateBucketSpanFactory(
|
||||
context.ml!.mlClient.callAsCurrentUser,
|
||||
context.core.elasticsearch.adminClient.callAsInternalUser,
|
||||
context.core.elasticsearch.legacy.client.callAsInternalUser,
|
||||
mlLicense.isSecurityEnabled() === false
|
||||
)(request.body)
|
||||
// this catch gets triggered when the estimation code runs without error
|
||||
|
@ -187,7 +187,7 @@ export function jobValidationRoutes({ router, mlLicense }: RouteInitialization,
|
|||
context.ml!.mlClient.callAsCurrentUser,
|
||||
request.body,
|
||||
version,
|
||||
context.core.elasticsearch.adminClient.callAsInternalUser,
|
||||
context.core.elasticsearch.legacy.client.callAsInternalUser,
|
||||
mlLicense.isSecurityEnabled() === false
|
||||
);
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ export async function bootstrapAnnotations({ index, core, context }: Params) {
|
|||
getScopedAnnotationsClient: (requestContext: RequestHandlerContext, request: KibanaRequest) => {
|
||||
return createAnnotationsClient({
|
||||
index,
|
||||
apiCaller: requestContext.core.elasticsearch.dataClient.callAsCurrentUser,
|
||||
apiCaller: requestContext.core.elasticsearch.legacy.client.callAsCurrentUser,
|
||||
logger,
|
||||
license: requestContext.licensing?.license,
|
||||
});
|
||||
|
|
|
@ -50,7 +50,7 @@ export function registerAnnotationAPIs({
|
|||
});
|
||||
}
|
||||
|
||||
const apiCaller = context.core.elasticsearch.dataClient.callAsCurrentUser;
|
||||
const apiCaller = context.core.elasticsearch.legacy.client.callAsCurrentUser;
|
||||
|
||||
const client = createAnnotationsClient({
|
||||
index,
|
||||
|
|
|
@ -23,7 +23,7 @@ export function registerExecuteRoute({ router, license }: RouteDependencies) {
|
|||
const body = req.body;
|
||||
|
||||
try {
|
||||
const callAsCurrentUser = ctx.core.elasticsearch.dataClient.callAsCurrentUser;
|
||||
const callAsCurrentUser = ctx.core.elasticsearch.legacy.client.callAsCurrentUser;
|
||||
const response = await callAsCurrentUser('scriptsPainlessExecute', {
|
||||
body,
|
||||
});
|
||||
|
|
|
@ -3,11 +3,12 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
import { kibanaResponseFactory, RequestHandlerContext } from '../../../../../../src/core/server';
|
||||
import { kibanaResponseFactory } from '../../../../../../src/core/server';
|
||||
import { register } from './add_route';
|
||||
import { API_BASE_PATH } from '../../../common/constants';
|
||||
import { LicenseStatus } from '../../types';
|
||||
|
||||
import { xpackMocks } from '../../../../../mocks';
|
||||
import {
|
||||
elasticsearchServiceMock,
|
||||
httpServerMock,
|
||||
|
@ -59,13 +60,8 @@ describe('ADD remote clusters', () => {
|
|||
headers: { authorization: 'foo' },
|
||||
});
|
||||
|
||||
const mockContext = ({
|
||||
core: {
|
||||
elasticsearch: {
|
||||
dataClient: mockScopedClusterClient,
|
||||
},
|
||||
},
|
||||
} as unknown) as RequestHandlerContext;
|
||||
const mockContext = xpackMocks.createRequestHandlerContext();
|
||||
mockContext.core.elasticsearch.legacy.client = mockScopedClusterClient;
|
||||
|
||||
const response = await handler(mockContext, mockRequest, kibanaResponseFactory);
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ export const register = (deps: RouteDependencies): void => {
|
|||
response
|
||||
) => {
|
||||
try {
|
||||
const callAsCurrentUser = ctx.core.elasticsearch.dataClient.callAsCurrentUser;
|
||||
const callAsCurrentUser = ctx.core.elasticsearch.legacy.client.callAsCurrentUser;
|
||||
|
||||
const { name } = request.body;
|
||||
|
||||
|
|
|
@ -3,11 +3,12 @@
|
|||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
import { kibanaResponseFactory, RequestHandlerContext } from '../../../../../../src/core/server';
|
||||
import { kibanaResponseFactory } from '../../../../../../src/core/server';
|
||||
import { register } from './delete_route';
|
||||
import { API_BASE_PATH } from '../../../common/constants';
|
||||
import { LicenseStatus } from '../../types';
|
||||
|
||||
import { xpackMocks } from '../../../../../mocks';
|
||||
import {
|
||||
elasticsearchServiceMock,
|
||||
httpServerMock,
|
||||
|
@ -61,14 +62,8 @@ describe('DELETE remote clusters', () => {
|
|||
headers: { authorization: 'foo' },
|
||||
});
|
||||
|
||||
const mockContext = ({
|
||||
core: {
|
||||
elasticsearch: {
|
||||
dataClient: mockScopedClusterClient,
|
||||
},
|
||||
},
|
||||
} as unknown) as RequestHandlerContext;
|
||||
|
||||
const mockContext = xpackMocks.createRequestHandlerContext();
|
||||
mockContext.core.elasticsearch.legacy.client = mockScopedClusterClient;
|
||||
const response = await handler(mockContext, mockRequest, kibanaResponseFactory);
|
||||
|
||||
expect(response.status).toBe(asserts.statusCode);
|
||||
|
|
|
@ -29,7 +29,7 @@ export const register = (deps: RouteDependencies): void => {
|
|||
response
|
||||
) => {
|
||||
try {
|
||||
const callAsCurrentUser = ctx.core.elasticsearch.dataClient.callAsCurrentUser;
|
||||
const callAsCurrentUser = ctx.core.elasticsearch.legacy.client.callAsCurrentUser;
|
||||
|
||||
const { nameOrNames } = request.params;
|
||||
const names = nameOrNames.split(',');
|
||||
|
|
|
@ -5,11 +5,12 @@
|
|||
*/
|
||||
import Boom from 'boom';
|
||||
|
||||
import { kibanaResponseFactory, RequestHandlerContext } from '../../../../../../src/core/server';
|
||||
import { kibanaResponseFactory } from '../../../../../../src/core/server';
|
||||
import { register } from './get_route';
|
||||
import { API_BASE_PATH } from '../../../common/constants';
|
||||
import { LicenseStatus } from '../../types';
|
||||
|
||||
import { xpackMocks } from '../../../../../mocks';
|
||||
import {
|
||||
elasticsearchServiceMock,
|
||||
httpServerMock,
|
||||
|
@ -59,13 +60,8 @@ describe('GET remote clusters', () => {
|
|||
headers: { authorization: 'foo' },
|
||||
});
|
||||
|
||||
const mockContext = ({
|
||||
core: {
|
||||
elasticsearch: {
|
||||
dataClient: mockScopedClusterClient,
|
||||
},
|
||||
},
|
||||
} as unknown) as RequestHandlerContext;
|
||||
const mockContext = xpackMocks.createRequestHandlerContext();
|
||||
mockContext.core.elasticsearch.legacy.client = mockScopedClusterClient;
|
||||
|
||||
const response = await handler(mockContext, mockRequest, kibanaResponseFactory);
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import { RouteDependencies } from '../../types';
|
|||
export const register = (deps: RouteDependencies): void => {
|
||||
const allHandler: RequestHandler<unknown, unknown, unknown> = async (ctx, request, response) => {
|
||||
try {
|
||||
const callAsCurrentUser = await ctx.core.elasticsearch.dataClient.callAsCurrentUser;
|
||||
const callAsCurrentUser = await ctx.core.elasticsearch.legacy.client.callAsCurrentUser;
|
||||
const clusterSettings = await callAsCurrentUser('cluster.getSettings');
|
||||
|
||||
const transientClusterNames = Object.keys(
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue