diff --git a/src/plugins/data/opensearch_dashboards.json b/src/plugins/data/opensearch_dashboards.json index b8d1134cba6d..b75610115176 100644 --- a/src/plugins/data/opensearch_dashboards.json +++ b/src/plugins/data/opensearch_dashboards.json @@ -7,7 +7,7 @@ "expressions", "uiActions" ], - "optionalPlugins": ["usageCollection"], + "optionalPlugins": ["usageCollection", "dataSource"], "extraPublicDirs": ["common", "common/utils/abort_utils"], "requiredBundles": [ "usageCollection", @@ -15,4 +15,4 @@ "opensearchDashboardsReact", "inspector" ] -} +} \ No newline at end of file diff --git a/src/plugins/data/server/index_patterns/fetcher/lib/opensearch_api.ts b/src/plugins/data/server/index_patterns/fetcher/lib/opensearch_api.ts index ed1cd0e89ee8..4400925e4dd4 100644 --- a/src/plugins/data/server/index_patterns/fetcher/lib/opensearch_api.ts +++ b/src/plugins/data/server/index_patterns/fetcher/lib/opensearch_api.ts @@ -62,11 +62,13 @@ export async function callIndexAliasApi( ): Promise { try { if ('transport' in callCluster) { - return ((await callCluster.indices.getAlias({ - index: indices, - ignore_unavailable: true, - allow_no_indices: true, - })) as unknown) as Promise; // todo: Pending #... verify test + return ( + await callCluster.indices.getAlias({ + index: indices, + ignore_unavailable: true, + allow_no_indices: true, + }) + ).body as IndicesAliasResponse; } return (await callCluster('indices.getAlias', { @@ -98,12 +100,14 @@ export async function callFieldCapsApi( ) { try { if ('transport' in callCluster) { - return ((await callCluster.fieldCaps({ - index: indices, - fields: '*', - ignore_unavailable: true, - allow_no_indices: fieldCapsOptions.allowNoIndices, - })) as unknown) as FieldCapsResponse; // todo: Pending #... verify test + return ( + await callCluster.fieldCaps({ + index: indices, + fields: '*', + ignore_unavailable: true, + allow_no_indices: fieldCapsOptions.allowNoIndices, + }) + ).body as FieldCapsResponse; } return (await callCluster('fieldCaps', { diff --git a/src/plugins/data/server/index_patterns/routes.ts b/src/plugins/data/server/index_patterns/routes.ts index ab08c5754467..f41c15ccb381 100644 --- a/src/plugins/data/server/index_patterns/routes.ts +++ b/src/plugins/data/server/index_patterns/routes.ts @@ -58,7 +58,7 @@ export function registerRoutes(http: HttpServiceSetup) { }, }, async (context, request, response) => { - const callAsCurrentUser = decideClient(context, request); + const callAsCurrentUser = await decideClient(context, request); const indexPatterns = new IndexPatternsFetcher(callAsCurrentUser); const { pattern, meta_fields: metaFields } = request.query; @@ -118,7 +118,7 @@ export function registerRoutes(http: HttpServiceSetup) { }, }, async (context: RequestHandlerContext, request: any, response: any) => { - const callAsCurrentUser = decideClient(context, request); + const callAsCurrentUser = await decideClient(context, request); const indexPatterns = new IndexPatternsFetcher(callAsCurrentUser); const { pattern, interval, look_back: lookBack, meta_fields: metaFields } = request.query; @@ -151,9 +151,10 @@ export function registerRoutes(http: HttpServiceSetup) { ); } -const decideClient = (context: RequestHandlerContext, request: any) => { - if (request.query.data_source) { - // todo: # Pending +const decideClient = async (context: RequestHandlerContext, request: any) => { + const dataSourceId = request.query.data_source; + if (dataSourceId) { + return await context.dataSource.opensearch.getClient(dataSourceId); } return context.core.opensearch.legacy.client.callAsCurrentUser; diff --git a/src/plugins/index_pattern_management/server/routes/resolve_index.ts b/src/plugins/index_pattern_management/server/routes/resolve_index.ts index f70e6a41d385..510eeb367da8 100644 --- a/src/plugins/index_pattern_management/server/routes/resolve_index.ts +++ b/src/plugins/index_pattern_management/server/routes/resolve_index.ts @@ -58,12 +58,15 @@ export function registerResolveIndexRoute(router: IRouter): void { ? { expand_wildcards: req.query.expand_wildcards } : null; - if (req.query.data_source) { - // const result = await (await context.data_source.opensearch.getClient(req.query.data_source)).indices.resolveIndex({ - // name: encodeURIComponent(req.params.query), - // expand_wildcards: req.query.expand_wildcards, - // }); - // return res.ok({ body: result.body }); //todo: Pending # + const dataSourceId = req.query.data_source; + if (dataSourceId) { + const result = await ( + await context.dataSource.opensearch.getClient(dataSourceId) + ).indices.resolveIndex({ + name: encodeURIComponent(req.params.query), + expand_wildcards: req.query.expand_wildcards, + }); + return res.ok({ body: result.body }); } const result = await context.core.opensearch.legacy.client.callAsCurrentUser(