export type DeleteApiV1EnvironmentsEnvironmentIdArgs = {environmentId: string, cleanupAuditLogs?: boolean | undefined}; export type DeleteApiV1EnvironmentsEnvironmentIdOptions = {baseUrl?: string | undefined, Basic?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Delete Environment * * DELETE /v1/environments/{environmentId} */ export const deleteApiV1EnvironmentsEnvironmentId = async (args: DeleteApiV1EnvironmentsEnvironmentIdArgs, options?: DeleteApiV1EnvironmentsEnvironmentIdOptions) => { const {baseUrl = "https://api.configcat.com", fetch: fetchFn = fetch, Basic} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.cleanupAuditLogs != null) query.append("cleanupAuditLogs", String(args.cleanupAuditLogs)) if (Basic !== undefined) headers.set('authorization', `Basic ${btoa(`${Basic.username}:${Basic.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/environments/${encodeURIComponent(String(args.environmentId))}${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 };