Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML] New Platform server shim: update system routes #57835

Merged
merged 6 commits into from
Feb 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { IScopedClusterClient } from 'kibana/server';
import { Privileges, getDefaultPrivileges } from '../../../common/types/privileges';
import { XPackMainPlugin } from '../../../../xpack_main/server/xpack_main';
import { callWithRequestType } from '../../../common/types/kibana';
import { isSecurityDisabled } from '../../lib/security_utils';
import { upgradeCheckProvider } from './upgrade';
import { checkLicense } from '../check_license';
Expand All @@ -24,12 +24,12 @@ interface Response {
}

export function privilegesProvider(
callWithRequest: callWithRequestType,
callAsCurrentUser: IScopedClusterClient['callAsCurrentUser'],
xpackMainPlugin: XPackMainPlugin,
isMlEnabledInSpace: () => Promise<boolean>,
ignoreSpaces: boolean = false
) {
const { isUpgradeInProgress } = upgradeCheckProvider(callWithRequest);
const { isUpgradeInProgress } = upgradeCheckProvider(callAsCurrentUser);
async function getPrivileges(): Promise<Response> {
// get the default privileges, forced to be false.
const privileges = getDefaultPrivileges();
Expand Down Expand Up @@ -74,7 +74,7 @@ export function privilegesProvider(
} else {
// security enabled
// load all ml privileges for this user.
const { cluster } = await callWithRequest('ml.privilegeCheck', { body: mlPrivileges });
const { cluster } = await callAsCurrentUser('ml.privilegeCheck', { body: mlPrivileges });
setGettingPrivileges(cluster, privileges);
if (upgradeInProgress === false) {
// if an upgrade is in progress, don't apply the "setting"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { IScopedClusterClient } from 'kibana/server';
import { mlLog } from '../../client/log';
import { callWithRequestType } from '../../../common/types/kibana';

export function upgradeCheckProvider(callWithRequest: callWithRequestType) {
export function upgradeCheckProvider(callAsCurrentUser: IScopedClusterClient['callAsCurrentUser']) {
async function isUpgradeInProgress(): Promise<boolean> {
let upgradeInProgress = false;
try {
const info = await callWithRequest('ml.info');
const info = await callAsCurrentUser('ml.info');
// if ml indices are currently being migrated, upgrade_mode will be set to true
// pass this back with the privileges to allow for the disabling of UI controls.
upgradeInProgress = info.upgrade_mode === true;
Expand Down
8 changes: 7 additions & 1 deletion x-pack/legacy/plugins/ml/server/routes/apidoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@
"DeleteFilter",
"GetFiltersStats",
"Indices",
"FieldCaps"
"FieldCaps",
"SystemRoutes",
"HasPrivileges",
"MlCapabilities",
"MlNodeCount",
"MlInfo",
"MlEsSearch"
]
}
205 changes: 0 additions & 205 deletions x-pack/legacy/plugins/ml/server/routes/system.js

This file was deleted.

Loading