export type UpdateApiV1MachinesIdFilesPathArgs = {id: string, path: string, body: BodyInit}; export type UpdateApiV1MachinesIdFilesPathOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Upload a file. * * PUT /v1/machines/{id}/files/{path} */ export const updateApiV1MachinesIdFilesPath = async (args: UpdateApiV1MachinesIdFilesPathArgs, options?: UpdateApiV1MachinesIdFilesPathOptions) => { const {baseUrl = "https://api.smolmachines.com", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/octet-stream") if (ApiKeyAuth !== undefined) headers.set('authorization', `Bearer ${ApiKeyAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/machines/${encodeURIComponent(String(args.id))}/files/${encodeURIComponent(String(args.path))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };