Skip to content

Commit 4fa5942

Browse files
authored
[ML] New Platform server shim: update system routes (#57835)
* [ML] NP system routes * [ML] apidoc.json * [ML] address PR comments * [ML] fix apidoc methods, passing es_search endpoint payload * [ML] add dummy body validation for es_search, fix ignoreSpaces query param * [ML] _has_privileges validate body
1 parent cf743f3 commit 4fa5942

File tree

5 files changed

+261
-213
lines changed

5 files changed

+261
-213
lines changed

x-pack/legacy/plugins/ml/server/lib/check_privileges/check_privileges.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7+
import { IScopedClusterClient } from 'kibana/server';
78
import { Privileges, getDefaultPrivileges } from '../../../common/types/privileges';
89
import { XPackMainPlugin } from '../../../../xpack_main/server/xpack_main';
9-
import { callWithRequestType } from '../../../common/types/kibana';
1010
import { isSecurityDisabled } from '../../lib/security_utils';
1111
import { upgradeCheckProvider } from './upgrade';
1212
import { checkLicense } from '../check_license';
@@ -24,12 +24,12 @@ interface Response {
2424
}
2525

2626
export function privilegesProvider(
27-
callWithRequest: callWithRequestType,
27+
callAsCurrentUser: IScopedClusterClient['callAsCurrentUser'],
2828
xpackMainPlugin: XPackMainPlugin,
2929
isMlEnabledInSpace: () => Promise<boolean>,
3030
ignoreSpaces: boolean = false
3131
) {
32-
const { isUpgradeInProgress } = upgradeCheckProvider(callWithRequest);
32+
const { isUpgradeInProgress } = upgradeCheckProvider(callAsCurrentUser);
3333
async function getPrivileges(): Promise<Response> {
3434
// get the default privileges, forced to be false.
3535
const privileges = getDefaultPrivileges();
@@ -74,7 +74,7 @@ export function privilegesProvider(
7474
} else {
7575
// security enabled
7676
// load all ml privileges for this user.
77-
const { cluster } = await callWithRequest('ml.privilegeCheck', { body: mlPrivileges });
77+
const { cluster } = await callAsCurrentUser('ml.privilegeCheck', { body: mlPrivileges });
7878
setGettingPrivileges(cluster, privileges);
7979
if (upgradeInProgress === false) {
8080
// if an upgrade is in progress, don't apply the "setting"

x-pack/legacy/plugins/ml/server/lib/check_privileges/upgrade.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7+
import { IScopedClusterClient } from 'kibana/server';
78
import { mlLog } from '../../client/log';
8-
import { callWithRequestType } from '../../../common/types/kibana';
99

10-
export function upgradeCheckProvider(callWithRequest: callWithRequestType) {
10+
export function upgradeCheckProvider(callAsCurrentUser: IScopedClusterClient['callAsCurrentUser']) {
1111
async function isUpgradeInProgress(): Promise<boolean> {
1212
let upgradeInProgress = false;
1313
try {
14-
const info = await callWithRequest('ml.info');
14+
const info = await callAsCurrentUser('ml.info');
1515
// if ml indices are currently being migrated, upgrade_mode will be set to true
1616
// pass this back with the privileges to allow for the disabling of UI controls.
1717
upgradeInProgress = info.upgrade_mode === true;

x-pack/legacy/plugins/ml/server/routes/apidoc.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@
7878
"DeleteFilter",
7979
"GetFiltersStats",
8080
"Indices",
81-
"FieldCaps"
81+
"FieldCaps",
82+
"SystemRoutes",
83+
"HasPrivileges",
84+
"MlCapabilities",
85+
"MlNodeCount",
86+
"MlInfo",
87+
"MlEsSearch"
8288
]
8389
}

x-pack/legacy/plugins/ml/server/routes/system.js

Lines changed: 0 additions & 205 deletions
This file was deleted.

0 commit comments

Comments
 (0)