export type ArtifactFamily = 'anaconda_project' | 'anaconda_env' | 'cve' | 'conda' | 'python' | 'cran' | 'notebook' | 'docker' | 'sbom'; export type GetApiArtifactsArtifactFamilyArtifactNameArtifactFileDownloadArgs = {artifact_family: ArtifactFamily, artifact_name: string, artifact_file: string}; export type GetApiArtifactsArtifactFamilyArtifactNameArtifactFileDownloadOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download the artifact file * * GET /artifacts/{artifact_family}/{artifact_name}/{artifact_file}/download */ export const getApiArtifactsArtifactFamilyArtifactNameArtifactFileDownload = async (args: GetApiArtifactsArtifactFamilyArtifactNameArtifactFileDownloadArgs, options?: GetApiArtifactsArtifactFamilyArtifactNameArtifactFileDownloadOptions) => { const {baseUrl = "https://api.anaconda.cloud/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() const url = `${baseUrl.replace(/\/+$/, '')}/artifacts/${encodeURIComponent(String(args.artifact_family))}/${encodeURIComponent(String(args.artifact_name))}/${encodeURIComponent(String(args.artifact_file))}/download${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 undefined };