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

[Fleet] Remove deprecated epm APIs #198434

Merged
merged 33 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
27c3f48
[Fleet] Remove deprecated epm APIs
nchaulet Oct 30, 2024
ea89b50
fix types
nchaulet Oct 31, 2024
e36f1f8
remove experimental from GET /epm/categories
nchaulet Oct 31, 2024
ac9b09c
fix tests
nchaulet Oct 31, 2024
8a30d4e
[CI] Auto-commit changed files from 'node scripts/capture_oas_snapsho…
kibanamachine Oct 31, 2024
1ebe34e
fix test
nchaulet Oct 31, 2024
92e3c15
Merge branch 'feature-remove-deprecated-epm-apis' of github.com:nchau…
nchaulet Oct 31, 2024
98eae36
fix tests
nchaulet Oct 31, 2024
68c57bf
remove response from categories endpoint
nchaulet Nov 1, 2024
72ee474
Merge branch 'main' of github.com:elastic/kibana into feature-remove-…
nchaulet Nov 1, 2024
daae4d0
remove response and experimental parameter
nchaulet Nov 1, 2024
bf961e8
fix types
nchaulet Nov 1, 2024
557bb51
add more tests
nchaulet Nov 1, 2024
202e28c
[CI] Auto-commit changed files from 'node scripts/capture_oas_snapsho…
kibanamachine Nov 1, 2024
ee9854b
Merge branch 'feature-remove-deprecated-epm-apis' of github.com:nchau…
nchaulet Nov 1, 2024
a920902
[CI] Auto-commit changed files from 'make api-docs'
kibanamachine Nov 1, 2024
dc73119
fix tests
nchaulet Nov 1, 2024
b5d439c
remove more deprecated response body
nchaulet Nov 1, 2024
c0206e0
fix typo
nchaulet Nov 1, 2024
4e0771c
remove body for delete package apis
nchaulet Nov 1, 2024
87c54b3
[CI] Auto-commit changed files from 'node scripts/capture_oas_snapsho…
kibanamachine Nov 1, 2024
a6c5fb8
fix tests
nchaulet Nov 1, 2024
e7a8d2b
Merge branch 'feature-remove-deprecated-epm-apis' of github.com:nchau…
nchaulet Nov 1, 2024
447e599
fix tests
nchaulet Nov 1, 2024
d435587
[CI] Auto-commit changed files from 'make api-docs'
kibanamachine Nov 1, 2024
aee8acf
fix type
nchaulet Nov 2, 2024
df898cb
Merge branch 'main' of github.com:elastic/kibana into feature-remove-…
nchaulet Nov 4, 2024
4e0c8de
Merge branch 'feature-remove-deprecated-epm-apis' of github.com:nchau…
nchaulet Nov 4, 2024
25bb32b
Merge branch 'main' of github.com:elastic/kibana into feature-remove-…
nchaulet Nov 4, 2024
0a0caeb
fix tests
nchaulet Nov 4, 2024
b40a8ab
fix more tests
nchaulet Nov 4, 2024
ce150a3
fix after review
nchaulet Nov 5, 2024
3998d5d
Merge branch 'main' of github.com:elastic/kibana into feature-remove-…
nchaulet Nov 5, 2024
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
3,830 changes: 714 additions & 3,116 deletions oas_docs/bundle.json

Large diffs are not rendered by default.

3,830 changes: 714 additions & 3,116 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 @@ -531,8 +531,8 @@ export type PackageList = PackageListItem[];
export type PackageListItem = Installable<RegistrySearchResult> & {
id: string;
integration?: string;
installationInfo?: InstallationInfo;
savedObject?: InstallableSavedObject;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is savedObject still needed in PackageListItem type?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it still needed that interface is used to type the package server side, and we only populate installationInfo in the handler for public usage.

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