diff --git a/docs/Contributing/API-for-contributors.md b/docs/Contributing/API-for-contributors.md index 78136599461..fd840ae88fe 100644 --- a/docs/Contributing/API-for-contributors.md +++ b/docs/Contributing/API-for-contributors.md @@ -32,6 +32,7 @@ Unlike the [Fleet REST API documentation](../Using-Fleet/REST-API.md), only the - [Get device's policies](#get-devices-policies) - [Get device's API features](#get-devices-api-features) - [Get device's transparency URL](#get-devices-transparency-url) +- [Check if an installer exists](#check-if-an-installer-exists) - [Download an installer](#download-an-installer) ### Get queries spec @@ -1717,15 +1718,16 @@ Redirects to the transparency URL. Downloads a pre-built fleet-osquery installer with the given parameters. -`GET /api/_version_/fleet/download_installer/{kind}` +`POST /api/_version_/fleet/download_installer/{kind}` #### Parameters -| Name | Type | In | Description | -| ------------- | ------- | ----- | ------------------------------------------------------------------ | -| kind | string | path | The installer kind: pkg, msi, deb or rpm. | -| enroll_secret | string | query | The global enroll secret. | -| desktop | boolean | query | Set to `true` to ask for an installer that includes Fleet Desktop. | +| Name | Type | In | Description | +| ------------- | ------- | ---------------------- | ------------------------------------------------------------------ | +| kind | string | path | The installer kind: pkg, msi, deb or rpm. | +| enroll_secret | string | x-www-form-urlencoded | The global enroll secret. | +| token | string | x-www-form-urlencoded | The authentication token. | +| desktop | boolean | x-www-form-urlencoded | Set to `true` to ask for an installer that includes Fleet Desktop. | ##### Default response @@ -1746,4 +1748,31 @@ If an installer with the provided parameters is found, the installer is returned This error occurs if an installer with the provided parameters doesn't exist. +### Check if an installer exists + +Checks if a pre-built fleet-osquery installer with the given parameters exists. + +`HEAD /api/_version_/fleet/download_installer/{kind}` + +#### Parameters + +| Name | Type | In | Description | +| ------------- | ------- | ----- | ------------------------------------------------------------------ | +| kind | string | path | The installer kind: pkg, msi, deb or rpm. | +| enroll_secret | string | query | The global enroll secret. | +| desktop | boolean | query | Set to `true` to ask for an installer that includes Fleet Desktop. | + +##### Default response + +`Status: 200` + +If an installer with the provided parameters is found. + +##### Installer doesn't exist + +`Status: 400` + +If an installer with the provided parameters doesn't exist. + + diff --git a/frontend/components/AddHostsModal/DownloadInstallers/DownloadInstallers.tsx b/frontend/components/AddHostsModal/DownloadInstallers/DownloadInstallers.tsx index 316e5d4a857..0d06f0d66f7 100644 --- a/frontend/components/AddHostsModal/DownloadInstallers/DownloadInstallers.tsx +++ b/frontend/components/AddHostsModal/DownloadInstallers/DownloadInstallers.tsx @@ -1,5 +1,4 @@ -import React, { useState } from "react"; -import FileSaver from "file-saver"; +import React, { FunctionComponent, useState } from "react"; import { IInstallerPlatform, @@ -7,6 +6,9 @@ import { INSTALLER_PLATFORM_BY_TYPE, INSTALLER_TYPE_BY_PLATFORM, } from "interfaces/installer"; +import ENDPOINTS from "utilities/endpoints"; +import local from "utilities/local"; +import URL_PREFIX from "router/url_prefix"; import installerAPI from "services/entities/installers"; import Button from "components/buttons/Button"; @@ -28,6 +30,17 @@ interface IDownloadInstallersProps { onCancel: () => void; } +interface IDownloadFormProps { + url: string; + onSubmit: (event: React.FormEvent) => void; + token: string | null; + enrollSecret: string; + includeDesktop: boolean; + selectedInstaller: string | undefined; + isDownloading: boolean; + isDownloadSuccess: boolean; +} + const baseClass = "download-installers"; const displayOrder = [ @@ -60,37 +73,81 @@ const displayIcon = (platform: IInstallerPlatform, isSelected: boolean) => { } }; +const DownloadForm: FunctionComponent = ({ + url, + onSubmit, + token, + enrollSecret, + includeDesktop, + selectedInstaller, + isDownloading, + isDownloadSuccess, +}) => { + return ( +
+ + + +