forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] New Platform server shim: update analytics routes to use new pla…
…tform router (elastic#53521) * update dfAnalytics routes to use np router * add route schemas and only show error message * convert route file to ts and set handlers inline * update df analytics param type * update mlClient type and assert mlClient is not null * handle errors correctly * ensure error status gets passed correctly to wrapper
- Loading branch information
1 parent
cfec717
commit eb74196
Showing
8 changed files
with
426 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* 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 { boomify, isBoom } from 'boom'; | ||
import { ResponseError, CustomHttpResponseOptions } from 'src/core/server'; | ||
|
||
export function wrapError(error: any): CustomHttpResponseOptions<ResponseError> { | ||
const boom = isBoom(error) ? error : boomify(error, { statusCode: error.status }); | ||
return { | ||
body: boom, | ||
headers: boom.output.headers, | ||
statusCode: boom.output.statusCode, | ||
}; | ||
} |
43 changes: 43 additions & 0 deletions
43
x-pack/legacy/plugins/ml/server/new_platform/data_analytics_schema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* 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 { schema } from '@kbn/config-schema'; | ||
|
||
export const dataAnalyticsJobConfigSchema = { | ||
description: schema.maybe(schema.string()), | ||
dest: schema.object({ | ||
index: schema.string(), | ||
results_field: schema.maybe(schema.string()), | ||
}), | ||
source: schema.object({ | ||
index: schema.string(), | ||
}), | ||
analysis: schema.any(), | ||
analyzed_fields: schema.any(), | ||
model_memory_limit: schema.string(), | ||
}; | ||
|
||
export const dataAnalyticsEvaluateSchema = { | ||
index: schema.string(), | ||
query: schema.maybe(schema.any()), | ||
evaluation: schema.maybe( | ||
schema.object({ | ||
regression: schema.maybe(schema.any()), | ||
classification: schema.maybe(schema.any()), | ||
}) | ||
), | ||
}; | ||
|
||
export const dataAnalyticsExplainSchema = { | ||
description: schema.maybe(schema.string()), | ||
dest: schema.maybe(schema.any()), | ||
source: schema.object({ | ||
index: schema.string(), | ||
}), | ||
analysis: schema.any(), | ||
analyzed_fields: schema.maybe(schema.any()), | ||
model_memory_limit: schema.maybe(schema.string()), | ||
}; |
37 changes: 37 additions & 0 deletions
37
x-pack/legacy/plugins/ml/server/new_platform/licence_check_pre_routing_factory.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* 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 { | ||
KibanaRequest, | ||
KibanaResponseFactory, | ||
RequestHandler, | ||
RequestHandlerContext, | ||
} from 'src/core/server'; | ||
import { PLUGIN_ID, MlXpackMainPlugin } from './plugin'; | ||
|
||
export const licensePreRoutingFactory = ( | ||
xpackMainPlugin: MlXpackMainPlugin, | ||
handler: RequestHandler<any, any, any> | ||
): RequestHandler<any, any, any> => { | ||
// License checking and enable/disable logic | ||
return function licensePreRouting( | ||
ctx: RequestHandlerContext, | ||
request: KibanaRequest, | ||
response: KibanaResponseFactory | ||
) { | ||
const licenseCheckResults = xpackMainPlugin.info.feature(PLUGIN_ID).getLicenseCheckResults(); | ||
|
||
if (!licenseCheckResults.isAvailable) { | ||
return response.forbidden({ | ||
body: { | ||
message: licenseCheckResults.message, | ||
}, | ||
}); | ||
} | ||
|
||
return handler(ctx, request, response); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
174 changes: 0 additions & 174 deletions
174
x-pack/legacy/plugins/ml/server/routes/data_frame_analytics.js
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.