export type GetApiSnifferIdPcapArgs = {'X-Auth-Token': string, id: string}; export type GetApiSnifferIdPcapOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Sniffer get a pcap file * * GET /sniffer/{id}/pcap */ export const getApiSnifferIdPcap = async (args: GetApiSnifferIdPcapArgs, options: GetApiSnifferIdPcapOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['X-Auth-Token'] != null) headers.set("X-Auth-Token", String(args['X-Auth-Token'])) const url = `${baseUrl.replace(/\/+$/, '')}/sniffer/${encodeURIComponent(String(args.id))}/pcap${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 };