export type CopyModelRequestV1 = {newModelName: string, folderPath: string}; export type CreateApiApiV1ModelsModelIdCopyArgs = {ModelId: number, body: CopyModelRequestV1}; export type CreateApiApiV1ModelsModelIdCopyOptions = {baseUrl: string, APIToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Initiate an asynchronous copy of a model. Returns a token to check copy status. * * POST /api/v1/Models/{ModelId}/Copy */ export const createApiApiV1ModelsModelIdCopy = async (args: CreateApiApiV1ModelsModelIdCopyArgs, options: CreateApiApiV1ModelsModelIdCopyOptions) => { const {baseUrl, fetch: fetchFn = fetch, APIToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (APIToken !== undefined) headers.set('authorization', `Bearer ${APIToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/Models/${encodeURIComponent(String(args.ModelId))}/Copy${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 };