export type GetApiV1MachinesIdLogsArgs = {id: string, follow?: boolean | undefined, tail?: number | undefined}; export type GetApiV1MachinesIdLogsOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Stream machine console logs. * * GET /v1/machines/{id}/logs */ export const getApiV1MachinesIdLogs = async (args: GetApiV1MachinesIdLogsArgs, options?: GetApiV1MachinesIdLogsOptions) => { const {baseUrl = "https://api.smolmachines.com", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/plain") if (args.follow != null) query.append("follow", String(args.follow)) if (args.tail != null) query.append("tail", String(args.tail)) if (ApiKeyAuth !== undefined) headers.set('authorization', `Bearer ${ApiKeyAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/machines/${encodeURIComponent(String(args.id))}/logs${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };