export type UpdateApiApiV2PresetsPresetNameStatusArgs = {preset_name: string, provider?: string | undefined, body: {enabled?: boolean | undefined}}; export type UpdateApiApiV2PresetsPresetNameStatusOptions = {baseUrl: string, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Updates the status of a preset. It can enable or disable it, so that it won't be listed by the list endpoints. * * PUT /api/v2/presets/{preset_name}/status */ export const updateApiApiV2PresetsPresetNameStatus = async (args: UpdateApiApiV2PresetsPresetNameStatusArgs, options: UpdateApiApiV2PresetsPresetNameStatusOptions) => { const {baseUrl, fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.provider != null) query.append("provider", String(args.provider)) if (apiKey !== undefined) headers.set("Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/presets/${encodeURIComponent(String(args.preset_name))}/status${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };