export type DeleteApiDomainsArgs = {hostnames?: Array | undefined, labels?: Array | undefined}; export type DeleteApiDomainsOptions = {baseUrl?: string | undefined, APIKeyInHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Remove custom domains * * DELETE /domains */ export const deleteApiDomains = async (args: DeleteApiDomainsArgs, options?: DeleteApiDomainsOptions) => { const {baseUrl = "https://cyber-risk.upguard.com/api/public", fetch: fetchFn = fetch, APIKeyInHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() for (const item of args.hostnames ?? []) query.append("hostnames", String(item)) for (const item of args.labels ?? []) query.append("labels", String(item)) if (APIKeyInHeader !== undefined) headers.set("Authorization", APIKeyInHeader) const url = `${baseUrl.replace(/\/+$/, '')}/domains${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };