Skip to content

Commit bc92fa2

Browse files
migrate UA to new es-js client
1 parent f6813b8 commit bc92fa2

27 files changed

Lines changed: 292 additions & 282 deletions

x-pack/plugins/upgrade_assistant/common/types.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66

77
import { SavedObject, SavedObjectAttributes } from 'src/core/public';
8-
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
9-
import type { DeprecationInfo } from '../../../../src/core/server/elasticsearch/legacy/api_types';
108

119
export enum ReindexStep {
1210
// Enum values are spaced out by 10 to give us room to insert steps in between.
@@ -165,6 +163,23 @@ export interface UpgradeAssistantTelemetrySavedObjectAttributes {
165163
[key: string]: any;
166164
}
167165

166+
export type MIGRATION_DEPRECATION_LEVEL = 'none' | 'info' | 'warning' | 'critical';
167+
export interface DeprecationInfo {
168+
level: MIGRATION_DEPRECATION_LEVEL;
169+
message: string;
170+
url: string;
171+
details?: string;
172+
}
173+
174+
export interface IndexSettingsDeprecationInfo {
175+
[indexName: string]: DeprecationInfo[];
176+
}
177+
export interface DeprecationAPIResponse {
178+
cluster_settings: DeprecationInfo[];
179+
ml_settings: DeprecationInfo[];
180+
node_settings: DeprecationInfo[];
181+
index_settings: IndexSettingsDeprecationInfo;
182+
}
168183
export interface EnrichedDeprecationInfo extends DeprecationInfo {
169184
index?: string;
170185
node?: string;

x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/constants.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66

77
import { IconColor } from '@elastic/eui';
88
import { invert } from 'lodash';
9-
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
10-
import type { DeprecationInfo } from '../../../../../../../../src/core/server/elasticsearch/legacy/api_types';
9+
import { MIGRATION_DEPRECATION_LEVEL } from '../../../../../common/types';
1110

1211
export const LEVEL_MAP: { [level: string]: number } = {
1312
warning: 0,
1413
critical: 1,
1514
};
1615

17-
export const REVERSE_LEVEL_MAP: { [idx: number]: DeprecationInfo['level'] } = invert(
16+
export const REVERSE_LEVEL_MAP: { [idx: number]: MIGRATION_DEPRECATION_LEVEL } = invert(
1817
LEVEL_MAP
1918
) as any;
2019

x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/controls.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import React, { FunctionComponent, useState } from 'react';
88
import { i18n } from '@kbn/i18n';
99
import { EuiButton, EuiFieldSearch, EuiFlexGroup, EuiFlexItem, EuiCallOut } from '@elastic/eui';
1010
import { FormattedMessage } from '@kbn/i18n/react';
11-
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
12-
import type { DeprecationInfo } from '../../../../../../../../src/core/server/elasticsearch/legacy/api_types';
11+
import { DeprecationInfo } from '../../../../../common/types';
1312
import { GroupByOption, LevelFilterOption, LoadingState } from '../../types';
1413
import { FilterBar } from './filter_bar';
1514
import { GroupByBar } from './group_by_bar';

x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/grouped.test.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ import React from 'react';
99
import { mountWithIntl, shallowWithIntl } from '@kbn/test/jest';
1010
import { EuiBadge, EuiPagination } from '@elastic/eui';
1111

12-
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
13-
import type { DeprecationInfo } from '../../../../../../../../../src/core/server/elasticsearch/legacy/api_types';
14-
import { EnrichedDeprecationInfo } from '../../../../../../common/types';
12+
import { DeprecationInfo, EnrichedDeprecationInfo } from '../../../../../../common/types';
1513
import { GroupByOption, LevelFilterOption } from '../../../types';
1614
import { DeprecationAccordion, filterDeps, GroupedDeprecations } from './grouped';
1715

x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/grouped.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ import {
1818
} from '@elastic/eui';
1919
import { FormattedMessage } from '@kbn/i18n/react';
2020

21-
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
22-
import type { DeprecationInfo } from '../../../../../../../../../src/core/server/elasticsearch/legacy/api_types';
23-
import { EnrichedDeprecationInfo } from '../../../../../../common/types';
21+
import { DeprecationInfo, EnrichedDeprecationInfo } from '../../../../../../common/types';
2422
import { GroupByOption, LevelFilterOption } from '../../../types';
2523

2624
import { DeprecationCountSummary } from './count_summary';

x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/health.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import React, { FunctionComponent } from 'react';
1010
import { EuiBadge, EuiToolTip } from '@elastic/eui';
1111
import { i18n } from '@kbn/i18n';
1212

13-
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
14-
import type { DeprecationInfo } from '../../../../../../../../../src/core/server/elasticsearch/legacy/api_types';
13+
import { DeprecationInfo, MIGRATION_DEPRECATION_LEVEL } from '../../../../../../common/types';
1514
import { COLOR_MAP, LEVEL_MAP, REVERSE_LEVEL_MAP } from '../constants';
1615

1716
const LocalizedLevels: { [level: string]: string } = {
@@ -37,7 +36,7 @@ interface DeprecationHealthProps {
3736
single?: boolean;
3837
}
3938

40-
const SingleHealth: FunctionComponent<{ level: DeprecationInfo['level']; label: string }> = ({
39+
const SingleHealth: FunctionComponent<{ level: MIGRATION_DEPRECATION_LEVEL; label: string }> = ({
4140
level,
4241
label,
4342
}) => (
@@ -81,7 +80,7 @@ export const DeprecationHealth: FunctionComponent<DeprecationHealthProps> = ({
8180
.map(([numLevel, stringLevel]) => (
8281
<SingleHealth
8382
key={stringLevel}
84-
level={stringLevel as DeprecationInfo['level']}
83+
level={stringLevel as MIGRATION_DEPRECATION_LEVEL}
8584
label={`${countByLevel[numLevel]} ${LocalizedLevels[stringLevel]}`}
8685
/>
8786
))}

x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/deprecations/list.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66

77
import React, { FunctionComponent } from 'react';
88

9-
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
10-
import type { DeprecationInfo } from '../../../../../../../../../src/core/server/elasticsearch/legacy/api_types';
11-
import { EnrichedDeprecationInfo } from '../../../../../../common/types';
9+
import { DeprecationInfo, EnrichedDeprecationInfo } from '../../../../../../common/types';
1210
import { GroupByOption } from '../../../types';
1311

1412
import { COLOR_MAP, LEVEL_MAP } from '../constants';

x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/filter_bar.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66

77
import { mount, shallow } from 'enzyme';
88
import React from 'react';
9+
import { DeprecationInfo } from '../../../../../common/types';
910

10-
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
11-
import type { DeprecationInfo } from '../../../../../../../../src/core/server/elasticsearch/legacy/api_types';
1211
import { LevelFilterOption } from '../../types';
1312
import { FilterBar } from './filter_bar';
1413

x-pack/plugins/upgrade_assistant/public/application/components/tabs/checkup/filter_bar.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import React from 'react';
1010
import { EuiFilterButton, EuiFilterGroup, EuiFlexItem } from '@elastic/eui';
1111
import { i18n } from '@kbn/i18n';
1212

13-
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
14-
import type { DeprecationInfo } from '../../../../../../../../src/core/server/elasticsearch/legacy/api_types';
13+
import { DeprecationInfo } from '../../../../../common/types';
1514
import { LevelFilterOption } from '../../types';
1615

1716
const LocalizedOptions: { [option: string]: string } = {

x-pack/plugins/upgrade_assistant/server/lib/es_deprecation_logging_apis.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,30 @@ import {
1212

1313
describe('getDeprecationLoggingStatus', () => {
1414
it('calls cluster.getSettings', async () => {
15-
const dataClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
15+
const dataClient = elasticsearchServiceMock.createScopedClusterClient();
1616
await getDeprecationLoggingStatus(dataClient);
17-
expect(dataClient.callAsCurrentUser).toHaveBeenCalledWith('cluster.getSettings', {
18-
includeDefaults: true,
17+
expect(dataClient.asCurrentUser.cluster.getSettings).toHaveBeenCalledWith({
18+
include_defaults: true,
1919
});
2020
});
2121
});
2222

2323
describe('setDeprecationLogging', () => {
2424
describe('isEnabled = true', () => {
2525
it('calls cluster.putSettings with logger.deprecation = WARN', async () => {
26-
const dataClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
26+
const dataClient = elasticsearchServiceMock.createScopedClusterClient();
2727
await setDeprecationLogging(dataClient, true);
28-
expect(dataClient.callAsCurrentUser).toHaveBeenCalledWith('cluster.putSettings', {
28+
expect(dataClient.asCurrentUser.cluster.putSettings).toHaveBeenCalledWith({
2929
body: { transient: { 'logger.deprecation': 'WARN' } },
3030
});
3131
});
3232
});
3333

3434
describe('isEnabled = false', () => {
3535
it('calls cluster.putSettings with logger.deprecation = ERROR', async () => {
36-
const dataClient = elasticsearchServiceMock.createLegacyScopedClusterClient();
36+
const dataClient = elasticsearchServiceMock.createScopedClusterClient();
3737
await setDeprecationLogging(dataClient, false);
38-
expect(dataClient.callAsCurrentUser).toHaveBeenCalledWith('cluster.putSettings', {
38+
expect(dataClient.asCurrentUser.cluster.putSettings).toHaveBeenCalledWith({
3939
body: { transient: { 'logger.deprecation': 'ERROR' } },
4040
});
4141
});

0 commit comments

Comments
 (0)