mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[ML] Switching to new find file structure endpoint (#91802)
* [ML] Switching to new find file structure endpoint * js client change
This commit is contained in:
parent
619a658227
commit
60e63aa53b
6 changed files with 15 additions and 17 deletions
|
@ -96,7 +96,7 @@
|
|||
"@babel/core": "^7.12.10",
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@elastic/datemath": "link:packages/elastic-datemath",
|
||||
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary",
|
||||
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.2",
|
||||
"@elastic/ems-client": "7.12.0",
|
||||
"@elastic/eui": "31.7.0",
|
||||
"@elastic/filesaver": "1.1.2",
|
||||
|
|
|
@ -196,9 +196,6 @@ export function getMlClient(
|
|||
await jobIdsCheck('data-frame-analytics', p);
|
||||
return mlClient.explainDataFrameAnalytics(...p);
|
||||
},
|
||||
async findFileStructure(...p: Parameters<MlClient['findFileStructure']>) {
|
||||
return mlClient.findFileStructure(...p);
|
||||
},
|
||||
async flushJob(...p: Parameters<MlClient['flushJob']>) {
|
||||
await jobIdsCheck('anomaly-detector', p);
|
||||
return mlClient.flushJob(...p);
|
||||
|
|
|
@ -29,7 +29,6 @@ export type MlClientParams =
|
|||
| Parameters<MlClient['estimateModelMemory']>
|
||||
| Parameters<MlClient['evaluateDataFrame']>
|
||||
| Parameters<MlClient['explainDataFrameAnalytics']>
|
||||
| Parameters<MlClient['findFileStructure']>
|
||||
| Parameters<MlClient['flushJob']>
|
||||
| Parameters<MlClient['forecast']>
|
||||
| Parameters<MlClient['getBuckets']>
|
||||
|
|
|
@ -5,20 +5,22 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { IScopedClusterClient } from 'kibana/server';
|
||||
import {
|
||||
AnalysisResult,
|
||||
FormattedOverrides,
|
||||
InputOverrides,
|
||||
FindFileStructureResponse,
|
||||
} from '../../../common/types/file_datavisualizer';
|
||||
import type { MlClient } from '../../lib/ml_client';
|
||||
|
||||
export type InputData = any[];
|
||||
|
||||
export function fileDataVisualizerProvider(mlClient: MlClient) {
|
||||
export function fileDataVisualizerProvider(client: IScopedClusterClient) {
|
||||
async function analyzeFile(data: InputData, overrides: InputOverrides): Promise<AnalysisResult> {
|
||||
overrides.explain = overrides.explain === undefined ? 'true' : overrides.explain;
|
||||
const { body } = await mlClient.findFileStructure<FindFileStructureResponse>({
|
||||
const {
|
||||
body,
|
||||
} = await client.asInternalUser.textStructure.findStructure<FindFileStructureResponse>({
|
||||
body: data,
|
||||
...overrides,
|
||||
});
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { IScopedClusterClient } from 'kibana/server';
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { MAX_FILE_SIZE_BYTES } from '../../../file_upload/common';
|
||||
import { InputOverrides } from '../../common/types/file_datavisualizer';
|
||||
|
@ -13,10 +14,9 @@ import { InputData, fileDataVisualizerProvider } from '../models/file_data_visua
|
|||
|
||||
import { RouteInitialization } from '../types';
|
||||
import { analyzeFileQuerySchema } from './schemas/file_data_visualizer_schema';
|
||||
import type { MlClient } from '../lib/ml_client';
|
||||
|
||||
function analyzeFiles(mlClient: MlClient, data: InputData, overrides: InputOverrides) {
|
||||
const { analyzeFile } = fileDataVisualizerProvider(mlClient);
|
||||
function analyzeFiles(client: IScopedClusterClient, data: InputData, overrides: InputOverrides) {
|
||||
const { analyzeFile } = fileDataVisualizerProvider(client);
|
||||
return analyzeFile(data, overrides);
|
||||
}
|
||||
|
||||
|
@ -48,9 +48,9 @@ export function fileDataVisualizerRoutes({ router, routeGuard }: RouteInitializa
|
|||
tags: ['access:ml:canFindFileStructure'],
|
||||
},
|
||||
},
|
||||
routeGuard.basicLicenseAPIGuard(async ({ mlClient, request, response }) => {
|
||||
routeGuard.basicLicenseAPIGuard(async ({ client, request, response }) => {
|
||||
try {
|
||||
const result = await analyzeFiles(mlClient, request.body, request.query);
|
||||
const result = await analyzeFiles(client, request.body, request.query);
|
||||
return response.ok({ body: result });
|
||||
} catch (e) {
|
||||
return response.customError(wrapError(e));
|
||||
|
|
|
@ -2167,10 +2167,10 @@
|
|||
version "0.0.0"
|
||||
uid ""
|
||||
|
||||
"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary":
|
||||
version "8.0.0-canary.1"
|
||||
resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.1.tgz#5cd0eda62531b71af66a08da6c3cebc26a73d4c0"
|
||||
integrity sha512-VhQ42wH+0OGmHSlc4It3bqGTL7mLuC2RIionJZBIuY5P6lwUMz7goelfyfTHoo+LStxz5QQ8Zt2xcnAnShTBJg==
|
||||
"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.2":
|
||||
version "8.0.0-canary.2"
|
||||
resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.2.tgz#476e22bc90fc4f422f7195f693fdcddb7f8e1897"
|
||||
integrity sha512-xYdVJ1MCAprVxd0rqmkBVof7I0N+e6VBCcr0UOwEYjvpQJTvu6PPQROBAAmtAAgvIKs4a8HmpArGgu5QJUnNjw==
|
||||
dependencies:
|
||||
debug "^4.1.1"
|
||||
hpagent "^0.1.1"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue