export type CreateApiPluginsNameDisableArgs = {name: string, force?: boolean | undefined}; export type CreateApiPluginsNameDisableOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Disable a plugin * * POST /plugins/{name}/disable */ export const createApiPluginsNameDisable = async (args: CreateApiPluginsNameDisableArgs, options: CreateApiPluginsNameDisableOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.force != null) query.append("force", String(args.force)) const url = `${baseUrl.replace(/\/+$/, '')}/plugins/${encodeURIComponent(String(args.name))}/disable${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };