export type UpdateApiApiV1VariantsVariantNamePromoteArgs = {variantName: string}; export type UpdateApiApiV1VariantsVariantNamePromoteOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Promotes a variant to become the default * * PUT /api/v1/variants/{variantName}/_promote */ export const updateApiApiV1VariantsVariantNamePromote = async (args: UpdateApiApiV1VariantsVariantNamePromoteArgs, options: UpdateApiApiV1VariantsVariantNamePromoteOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/variants/${encodeURIComponent(String(args.variantName))}/_promote${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };