export type GetApiApiWAFDestinationIndexHtmlArgs = {destination: string, date?: string | undefined};
export type GetApiApiWAFDestinationIndexHtmlOptions = {baseUrl: string, fetch?: typeof fetch | undefined};
/**
* Generates a WAF for export to a particular destination.
*
* GET /api/WAF/{destination}/index.html
*/
export const getApiApiWAFDestinationIndexHtml = async (args: GetApiApiWAFDestinationIndexHtmlArgs, options: GetApiApiWAFDestinationIndexHtmlOptions) => {
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))}/index.html${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
};