export type GetApiApiOrgIdSyntheticsIdArtifactArgs = {org_id: string, id: string, key: string}; export type GetApiApiOrgIdSyntheticsIdArtifactOptions = {baseUrl: string, Authorization?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download a synthetics run artifact * * GET /api/{org_id}/synthetics/{id}/artifact */ export const getApiApiOrgIdSyntheticsIdArtifact = async (args: GetApiApiOrgIdSyntheticsIdArtifactArgs, options: GetApiApiOrgIdSyntheticsIdArtifactOptions) => { const {baseUrl, fetch: fetchFn = fetch, Authorization} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/png") if (args.key != null) query.append("key", String(args.key)) if (Authorization !== undefined) headers.set("Authorization", Authorization) const url = `${baseUrl.replace(/\/+$/, '')}/api/${encodeURIComponent(String(args.org_id))}/synthetics/${encodeURIComponent(String(args.id))}/artifact${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() };