export type RenameDashboardSchema = {name: string}; export type PatchApiApiV3DashboardsDashboardIdArgs = {dashboard_id: string, body: RenameDashboardSchema}; export type PatchApiApiV3DashboardsDashboardIdOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Rename a dashboard * * PATCH /api/v3/dashboards/{dashboard_id} */ export const patchApiApiV3DashboardsDashboardId = async (args: PatchApiApiV3DashboardsDashboardIdArgs, options?: PatchApiApiV3DashboardsDashboardIdOptions) => { const {baseUrl = "https://codemagic.io", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKey !== undefined) headers.set("x-auth-token", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/v3/dashboards/${encodeURIComponent(String(args.dashboard_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 };