export type GetApiApiWAFDestinationArgs = {destination: string, date?: string | undefined}; export type GetApiApiWAFDestinationOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Generates a WAF for export to a particular destination. * * GET /api/WAF/{destination} */ export const getApiApiWAFDestination = async (args: GetApiApiWAFDestinationArgs, options: GetApiApiWAFDestinationOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.date != null) query.append("date", String(args.date)) const url = `${baseUrl.replace(/\/+$/, '')}/api/WAF/${encodeURIComponent(String(args.destination))}${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 };