export type PullZonePurgeModel = {CacheTag?: (string | null) | undefined}; export type CreateApiPullzoneIdPurgeCacheArgs = {id: number, body: PullZonePurgeModel | null}; export type CreateApiPullzoneIdPurgeCacheOptions = {baseUrl?: string | undefined, AccessKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Purge Cache * * POST /pullzone/{id}/purgeCache */ export const createApiPullzoneIdPurgeCache = async (args: CreateApiPullzoneIdPurgeCacheArgs, options?: CreateApiPullzoneIdPurgeCacheOptions) => { const {baseUrl = "https://api.bunny.net", fetch: fetchFn = fetch, AccessKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (AccessKey !== undefined) headers.set("AccessKey", AccessKey) const url = `${baseUrl.replace(/\/+$/, '')}/pullzone/${encodeURIComponent(String(args.id))}/purgeCache${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };