export type GetApiApiDevicesAgentBundlePathArgs = {path: string}; export type GetApiApiDevicesAgentBundlePathOptions = {baseUrl: string, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download an on-prem CLI bundle asset * * GET /api/devices/agent/bundle/{path} */ export const getApiApiDevicesAgentBundlePath = async (args: GetApiApiDevicesAgentBundlePathArgs, options: GetApiApiDevicesAgentBundlePathOptions) => { const {baseUrl, fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (ApiKeyAuth !== undefined) headers.set("x-api-key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/api/devices/agent/bundle/${encodeURIComponent(String(args.path))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };