diff --git a/x-pack/plugins/fleet/common/types/rest_spec/epm.ts b/x-pack/plugins/fleet/common/types/rest_spec/epm.ts index 4af01c1b14c92..e8dee14e40b30 100644 --- a/x-pack/plugins/fleet/common/types/rest_spec/epm.ts +++ b/x-pack/plugins/fleet/common/types/rest_spec/epm.ts @@ -196,6 +196,9 @@ export interface DeletePackageRequest { pkgName: string; pkgVersion: string; }; + query: { + force?: boolean; + }; } export interface DeletePackageResponse { diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/debug/components/integration_debugger.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/debug/components/integration_debugger.tsx index 30fc1b84964f3..3e8a4e758fe8a 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/debug/components/integration_debugger.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/debug/components/integration_debugger.tsx @@ -61,7 +61,13 @@ export const IntegrationDebugger: React.FunctionComponent = () => { const integrations = useQuery(['debug-integrations'], fetchInstalledIntegrations); const uninstallMutation = useMutation(async (integration: PackageListItem) => { - const response = await sendRemovePackage(integration.name, integration.version, true); + const response = await sendRemovePackage( + { + pkgName: integration.name, + pkgVersion: integration.version, + }, + { force: true } + ); if (response.error) { notifications.toasts.addError(response.error, { @@ -92,7 +98,13 @@ export const IntegrationDebugger: React.FunctionComponent = () => { }); const reinstallMutation = useMutation(async (integration: PackageListItem) => { - const uninstallResponse = await sendRemovePackage(integration.name, integration.version, true); + const uninstallResponse = await sendRemovePackage( + { + pkgName: integration.name, + pkgVersion: integration.version, + }, + { force: true } + ); if (uninstallResponse.error) { notifications.toasts.addError(uninstallResponse.error, { diff --git a/x-pack/plugins/fleet/public/applications/integrations/hooks/use_package_install.tsx b/x-pack/plugins/fleet/public/applications/integrations/hooks/use_package_install.tsx index f60e887e25fbb..579a711a36398 100644 --- a/x-pack/plugins/fleet/public/applications/integrations/hooks/use_package_install.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/hooks/use_package_install.tsx @@ -199,7 +199,7 @@ function usePackageInstall({ startServices }: { startServices: StartServices }) }: Pick & { redirectToVersion: string }) => { setPackageInstallStatus({ name, status: InstallStatus.uninstalling, version }); - const res = await sendRemovePackage(name, version); + const res = await sendRemovePackage({ pkgName: name, pkgVersion: version }); if (res.error) { setPackageInstallStatus({ name, status: InstallStatus.installed, version }); notifications.toasts.addWarning({ diff --git a/x-pack/plugins/fleet/public/hooks/use_request/epm.ts b/x-pack/plugins/fleet/public/hooks/use_request/epm.ts index c7d40e84abdd0..d339463beaf17 100644 --- a/x-pack/plugins/fleet/public/hooks/use_request/epm.ts +++ b/x-pack/plugins/fleet/public/hooks/use_request/epm.ts @@ -20,6 +20,7 @@ import type { GetLimitedPackagesResponse, GetInfoResponse, InstallPackageResponse, + DeletePackageRequest, DeletePackageResponse, UpdatePackageRequest, UpdatePackageResponse, @@ -270,16 +271,17 @@ export const sendBulkInstallPackages = ( }); }; -export const sendRemovePackage = (pkgName: string, pkgVersion: string, force: boolean = false) => { +export function sendRemovePackage( + { pkgName, pkgVersion }: DeletePackageRequest['params'], + query?: DeletePackageRequest['query'] +) { return sendRequest({ path: epmRouteService.getRemovePath(pkgName, pkgVersion), method: 'delete', version: API_VERSIONS.public.v1, - body: { - force, - }, + query, }); -}; +} export const sendRequestReauthorizeTransforms = ( pkgName: string, diff --git a/x-pack/plugins/fleet/public/types/index.ts b/x-pack/plugins/fleet/public/types/index.ts index a340b7311fdbe..099df2ce5a34f 100644 --- a/x-pack/plugins/fleet/public/types/index.ts +++ b/x-pack/plugins/fleet/public/types/index.ts @@ -120,6 +120,7 @@ export type { GetLimitedPackagesResponse, GetInfoResponse, InstallPackageResponse, + DeletePackageRequest, DeletePackageResponse, InstallationStatus, Installable,