export type CreateApiSmolmachinesV1MachinesArgs = {body: {source: Record, resources: Record, ttlSeconds: number, name?: string | undefined, network?: Record | undefined, env?: Record | undefined, workdir?: string | undefined, autoStopSeconds?: number | undefined, ephemeral?: boolean | undefined, mounts?: Array | undefined}}; export type CreateApiSmolmachinesV1MachinesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a new microVM. Minimal example: {"source":{"type":"image","reference":"alpine:3.20"},"resources":{"cpus":1,"memoryMb":512},"ttlSeconds":3600}. Poll GET /v1/machines/{id} until ready is true before running commands. * * POST /smolmachines/v1/machines */ export const createApiSmolmachinesV1Machines = async (args: CreateApiSmolmachinesV1MachinesArgs, options?: CreateApiSmolmachinesV1MachinesOptions) => { const {baseUrl = "https://api.orthogonal.com/mpp", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/smolmachines/v1/machines${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 };