Skip to content

Commit

Permalink
[Fleet] Remove deprecated epm APIs (#198434)
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet authored Nov 6, 2024
1 parent ce9f622 commit 15c1ceb
Show file tree
Hide file tree
Showing 31 changed files with 2,502 additions and 10,884 deletions.
3,830 changes: 714 additions & 3,116 deletions oas_docs/bundle.json

Large diffs are not rendered by default.

3,832 changes: 715 additions & 3,117 deletions oas_docs/bundle.serverless.json

Large diffs are not rendered by default.

2,622 changes: 466 additions & 2,156 deletions oas_docs/output/kibana.serverless.yaml

Large diffs are not rendered by default.

2,622 changes: 466 additions & 2,156 deletions oas_docs/output/kibana.yaml

Large diffs are not rendered by default.

14 changes: 6 additions & 8 deletions x-pack/plugins/fleet/common/constants/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,21 @@ export const LIMITED_CONCURRENCY_ROUTE_TAG = 'ingest:limited-concurrency';
const EPM_PACKAGES_MANY = `${EPM_API_ROOT}/packages`;
const EPM_PACKAGES_INSTALLED = `${EPM_API_ROOT}/packages/installed`;
const EPM_PACKAGES_BULK = `${EPM_PACKAGES_MANY}/_bulk`;
const EPM_PACKAGES_ONE_DEPRECATED = `${EPM_PACKAGES_MANY}/{pkgkey}`;
const EPM_PACKAGES_ONE_WITHOUT_VERSION = `${EPM_PACKAGES_MANY}/{pkgName}`;
const EPM_PACKAGES_ONE = `${EPM_PACKAGES_MANY}/{pkgName}/{pkgVersion}`;
const EPM_PACKAGES_ONE_WITH_OPTIONAL_VERSION = `${EPM_PACKAGES_MANY}/{pkgName}/{pkgVersion?}`;
export const EPM_API_ROUTES = {
BULK_INSTALL_PATTERN: EPM_PACKAGES_BULK,
LIST_PATTERN: EPM_PACKAGES_MANY,
INSTALLED_LIST_PATTERN: EPM_PACKAGES_INSTALLED,
LIMITED_LIST_PATTERN: `${EPM_PACKAGES_MANY}/limited`,
INFO_PATTERN: EPM_PACKAGES_ONE,
INFO_WITHOUT_VERSION_PATTERN: EPM_PACKAGES_ONE_WITHOUT_VERSION,
INFO_PATTERN: EPM_PACKAGES_ONE_WITH_OPTIONAL_VERSION,
DATA_STREAMS_PATTERN: `${EPM_API_ROOT}/data_streams`,
INSTALL_FROM_REGISTRY_PATTERN: EPM_PACKAGES_ONE,
INSTALL_FROM_REGISTRY_PATTERN: EPM_PACKAGES_ONE_WITH_OPTIONAL_VERSION,
INSTALL_BY_UPLOAD_PATTERN: EPM_PACKAGES_MANY,
CUSTOM_INTEGRATIONS_PATTERN: `${EPM_API_ROOT}/custom_integrations`,
DELETE_PATTERN: EPM_PACKAGES_ONE,
DELETE_PATTERN: EPM_PACKAGES_ONE_WITH_OPTIONAL_VERSION,
INSTALL_KIBANA_ASSETS_PATTERN: `${EPM_PACKAGES_ONE}/kibana_assets`,
DELETE_KIBANA_ASSETS_PATTERN: `${EPM_PACKAGES_ONE}/kibana_assets`,
FILEPATH_PATTERN: `${EPM_PACKAGES_ONE}/{filePath*}`,
Expand All @@ -45,10 +47,6 @@ export const EPM_API_ROUTES = {
BULK_ASSETS_PATTERN: `${EPM_API_ROOT}/bulk_assets`,
INPUTS_PATTERN: `${EPM_API_ROOT}/templates/{pkgName}/{pkgVersion}/inputs`,

INFO_PATTERN_DEPRECATED: EPM_PACKAGES_ONE_DEPRECATED,
INSTALL_FROM_REGISTRY_PATTERN_DEPRECATED: EPM_PACKAGES_ONE_DEPRECATED,
DELETE_PATTERN_DEPRECATED: EPM_PACKAGES_ONE_DEPRECATED,

REAUTHORIZE_TRANSFORMS: `${EPM_PACKAGES_ONE}/transforms/authorize`,
};

Expand Down
43 changes: 43 additions & 0 deletions x-pack/plugins/fleet/common/services/route.test.ts
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
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { epmRouteService } from './routes';

describe('Route services', () => {
describe('epmRouteService', () => {
describe('getInfoPath', () => {
it('should generate path with pkgVersion', () => {
expect(epmRouteService.getInfoPath('test', '1.0.0')).toBe(
'/api/fleet/epm/packages/test/1.0.0'
);
});
it('should generate path without pkgVersion', () => {
expect(epmRouteService.getInfoPath('test')).toBe('/api/fleet/epm/packages/test');
});
});
describe('getInstallPath', () => {
it('should generate path with pkgVersion', () => {
expect(epmRouteService.getInstallPath('test', '1.0.0')).toBe(
'/api/fleet/epm/packages/test/1.0.0'
);
});
it('should generate path without pkgVersion', () => {
expect(epmRouteService.getInstallPath('test')).toBe('/api/fleet/epm/packages/test');
});
});
describe('getRemovePath', () => {
it('should generate path with pkgVersion', () => {
expect(epmRouteService.getRemovePath('test', '1.0.0')).toBe(
'/api/fleet/epm/packages/test/1.0.0'
);
});
it('should generate path without pkgVersion', () => {
expect(epmRouteService.getRemovePath('test')).toBe('/api/fleet/epm/packages/test');
});
});
});
});
35 changes: 25 additions & 10 deletions x-pack/plugins/fleet/common/services/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ export const epmRouteService = {
getInfoPath: (pkgName: string, pkgVersion?: string) => {
if (pkgVersion) {
return EPM_API_ROUTES.INFO_PATTERN.replace('{pkgName}', pkgName).replace(
'{pkgVersion}',
'{pkgVersion?}',
pkgVersion
);
} else {
return EPM_API_ROUTES.INFO_PATTERN.replace('{pkgName}', pkgName).replace('/{pkgVersion}', '');
return EPM_API_ROUTES.INFO_PATTERN.replace('{pkgName}', pkgName).replace(
'/{pkgVersion?}',
''
);
}
},

Expand All @@ -63,20 +66,32 @@ export const epmRouteService = {
return `${EPM_API_ROOT}${filePath.replace('/package', '/packages')}`;
},

getInstallPath: (pkgName: string, pkgVersion: string) => {
return EPM_API_ROUTES.INSTALL_FROM_REGISTRY_PATTERN.replace('{pkgName}', pkgName)
.replace('{pkgVersion}', pkgVersion)
.replace(/\/$/, ''); // trim trailing slash
getInstallPath: (pkgName: string, pkgVersion?: string) => {
if (pkgVersion) {
return EPM_API_ROUTES.INSTALL_FROM_REGISTRY_PATTERN.replace('{pkgName}', pkgName)
.replace('{pkgVersion?}', pkgVersion)
.replace(/\/$/, ''); // trim trailing slash
} else {
return EPM_API_ROUTES.INSTALL_FROM_REGISTRY_PATTERN.replace('{pkgName}', pkgName)
.replace('/{pkgVersion?}', '')
.replace(/\/$/, ''); // trim trailing slash
}
},

getBulkInstallPath: () => {
return EPM_API_ROUTES.BULK_INSTALL_PATTERN;
},

getRemovePath: (pkgName: string, pkgVersion: string) => {
return EPM_API_ROUTES.DELETE_PATTERN.replace('{pkgName}', pkgName)
.replace('{pkgVersion}', pkgVersion)
.replace(/\/$/, ''); // trim trailing slash
getRemovePath: (pkgName: string, pkgVersion?: string) => {
if (pkgVersion) {
return EPM_API_ROUTES.DELETE_PATTERN.replace('{pkgName}', pkgName)
.replace('{pkgVersion?}', pkgVersion)
.replace(/\/$/, ''); // trim trailing slash
} else {
return EPM_API_ROUTES.DELETE_PATTERN.replace('{pkgName}', pkgName)
.replace('/{pkgVersion?}', '')
.replace(/\/$/, ''); // trim trailing slash
}
},

getInstallKibanaAssetsPath: (pkgName: string, pkgVersion: string) => {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/fleet/common/types/models/epm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,8 @@ export type PackageList = PackageListItem[];
export type PackageListItem = Installable<RegistrySearchResult> & {
id: string;
integration?: string;
installationInfo?: InstallationInfo;
savedObject?: InstallableSavedObject;
installationInfo?: InstallationInfo;
};
export type PackagesGroupedByStatus = Record<ValueOf<InstallationStatus>, PackageList>;
export type PackageInfo =
Expand Down
28 changes: 0 additions & 28 deletions x-pack/plugins/fleet/common/types/rest_spec/epm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,25 @@ import type {

export interface GetCategoriesRequest {
query: {
// deprecated in 8.6
experimental?: boolean;
prerelease?: boolean;
include_policy_templates?: boolean;
};
}

export interface GetCategoriesResponse {
items: CategorySummaryList;
// deprecated in 8.0
response?: CategorySummaryList;
}

export interface GetPackagesRequest {
query: {
category?: string;
// deprecated in 8.6
experimental?: boolean;
prerelease?: boolean;
excludeInstallStatus?: boolean;
};
}

export interface GetPackagesResponse {
items: PackageList;
// deprecated in 8.0
response?: PackageList;
}

export interface InstalledPackage {
Expand Down Expand Up @@ -79,8 +71,6 @@ export interface GetEpmDataStreamsResponse {
}
export interface GetLimitedPackagesResponse {
items: string[];
// deprecated in 8.0
response?: string[];
}

export interface GetFileRequest {
Expand All @@ -93,8 +83,6 @@ export interface GetFileRequest {

export interface GetInfoRequest {
params: {
// deprecated in 8.0
pkgkey?: string;
pkgName: string;
pkgVersion: string;
};
Expand All @@ -103,14 +91,10 @@ export interface GetInfoRequest {
export interface GetInfoResponse {
item: PackageInfo;
metadata?: PackageMetadata;
// deprecated in 8.0
response?: PackageInfo;
}

export interface UpdatePackageRequest {
params: {
// deprecated in 8.0
pkgkey?: string;
pkgName: string;
pkgVersion: string;
};
Expand All @@ -121,8 +105,6 @@ export interface UpdatePackageRequest {

export interface UpdatePackageResponse {
item: PackageInfo;
// deprecated in 8.0
response?: PackageInfo;
}

export interface GetStatsRequest {
Expand All @@ -137,8 +119,6 @@ export interface GetStatsResponse {

export interface InstallPackageRequest {
params: {
// deprecated in 8.0
pkgkey?: string;
pkgName: string;
pkgVersion: string;
};
Expand All @@ -149,8 +129,6 @@ export interface InstallPackageResponse {
_meta: {
install_source: InstallSource;
};
// deprecated in 8.0
response?: AssetReference[];
}

export interface IBulkInstallPackageHTTPError {
Expand All @@ -175,8 +153,6 @@ export interface BulkInstallPackageInfo {

export interface BulkInstallPackagesResponse {
items: Array<BulkInstallPackageInfo | IBulkInstallPackageHTTPError>;
// deprecated in 8.0
response?: Array<BulkInstallPackageInfo | IBulkInstallPackageHTTPError>;
}

export interface BulkInstallPackagesRequest {
Expand All @@ -191,8 +167,6 @@ export interface MessageResponse {

export interface DeletePackageRequest {
params: {
// deprecated in 8.0
pkgkey?: string;
pkgName: string;
pkgVersion: string;
};
Expand All @@ -202,8 +176,6 @@ export interface DeletePackageRequest {
}

export interface DeletePackageResponse {
// deprecated in 8.0
response?: AssetReference[];
items: AssetReference[];
}
export interface GetVerificationKeyIdResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const TutorialModuleNotice: TutorialModuleNoticeComponent = memo(({ moduleName }

const pkgInfo =
!isLoading &&
packagesData?.response &&
packagesData.response.find((pkg) => pkg.name === moduleName && pkg.name !== FLEET_APM_PACKAGE); // APM needs special handling
packagesData?.items &&
packagesData.items.find((pkg) => pkg.name === moduleName && pkg.name !== FLEET_APM_PACKAGE); // APM needs special handling

if (hasIntegrationsPermissions && pkgInfo) {
return (
Expand Down
14 changes: 7 additions & 7 deletions x-pack/plugins/fleet/public/search_provider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe('Package search provider', () => {
test('returns formatted results', () => {
getTestScheduler().run(({ expectObservable, hot }) => {
mockSendGetPackages.mockReturnValue(
hot('--(a|)', { a: { data: { response: testResponse } } })
hot('--(a|)', { a: { data: { items: testResponse } } })
);
setupMock.getStartServices.mockReturnValue(
hot('--(a|)', { a: [coreMock.createStart()] }) as any
Expand Down Expand Up @@ -217,7 +217,7 @@ describe('Package search provider', () => {

test('calls EPR once only', () => {
getTestScheduler().run(({ hot }) => {
mockSendGetPackages.mockReturnValue(hot('--(a|)', { a: { data: { response: [] } } }));
mockSendGetPackages.mockReturnValue(hot('--(a|)', { a: { data: { items: [] } } }));
setupMock.getStartServices.mockReturnValue(
hot('--(a|)', { a: [coreMock.createStart()] }) as any
);
Expand All @@ -237,7 +237,7 @@ describe('Package search provider', () => {

test('completes without returning results if aborted', () => {
getTestScheduler().run(({ expectObservable, hot }) => {
mockSendGetPackages.mockReturnValue(hot('--(a|)', { a: { data: { response: [] } } }));
mockSendGetPackages.mockReturnValue(hot('--(a|)', { a: { data: { items: [] } } }));
setupMock.getStartServices.mockReturnValue(
hot('--(a|)', { a: [coreMock.createStart()] }) as any
);
Expand All @@ -258,7 +258,7 @@ describe('Package search provider', () => {
test('respect maximum results', () => {
getTestScheduler().run(({ hot, expectObservable }) => {
mockSendGetPackages.mockReturnValue(
hot('--(a|)', { a: { data: { response: testResponse } } })
hot('--(a|)', { a: { data: { items: testResponse } } })
);
setupMock.getStartServices.mockReturnValue(
hot('--(a|)', { a: [coreMock.createStart()] }) as any
Expand Down Expand Up @@ -292,7 +292,7 @@ describe('Package search provider', () => {
test('without packages tag, without search term', () => {
getTestScheduler().run(({ hot, expectObservable }) => {
mockSendGetPackages.mockReturnValue(
hot('--(a|)', { a: { data: { response: testResponse } } })
hot('--(a|)', { a: { data: { items: testResponse } } })
);
setupMock.getStartServices.mockReturnValue(
hot('--(a|)', { a: [coreMock.createStart()] }) as any
Expand All @@ -314,7 +314,7 @@ describe('Package search provider', () => {
test('with integration tag, with no search term', () => {
getTestScheduler().run(({ hot, expectObservable }) => {
mockSendGetPackages.mockReturnValue(
hot('--(a|)', { a: { data: { response: testResponse } } })
hot('--(a|)', { a: { data: { items: testResponse } } })
);
setupMock.getStartServices.mockReturnValue(
hot('--(a|)', { a: [coreMock.createStart()] }) as any
Expand Down Expand Up @@ -397,7 +397,7 @@ describe('Package search provider', () => {
test('with integration tag, with search term', () => {
getTestScheduler().run(({ hot, expectObservable }) => {
mockSendGetPackages.mockReturnValue(
hot('--(a|)', { a: { data: { response: testResponse } } })
hot('--(a|)', { a: { data: { items: testResponse } } })
);
setupMock.getStartServices.mockReturnValue(
hot('--(a|)', { a: [coreMock.createStart()] }) as any
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/fleet/public/search_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const createPackages$ = () =>
if (error) {
throw error;
}
return data?.response ?? [];
return data?.items ?? [];
}),
shareReplay(1)
);
Expand Down Expand Up @@ -86,7 +86,7 @@ export const createPackageSearchProvider = (core: CoreSetup): GlobalSearchResult
shareReplay(1)
);

let packages$: undefined | Observable<GetPackagesResponse['response']>;
let packages$: undefined | Observable<GetPackagesResponse['items']>;

const getPackages$ = () => {
if (!packages$) {
Expand Down
Loading

0 comments on commit 15c1ceb

Please sign in to comment.