export type DeleteApiIpsArgs = {ips?: Array | undefined, labels?: Array | undefined}; export type DeleteApiIpsOptions = {baseUrl?: string | undefined, APIKeyInHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Remove custom ips * * DELETE /ips */ export const deleteApiIps = async (args: DeleteApiIpsArgs, options?: DeleteApiIpsOptions) => { 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.ips ?? []) query.append("ips", String(item)) for (const item of args.labels ?? []) query.append("labels", String(item)) if (APIKeyInHeader !== undefined) headers.set("Authorization", APIKeyInHeader) const url = `${baseUrl.replace(/\/+$/, '')}/ips${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 };