export type CreateApiContainersIdAttachArgs = {id: string, detachKeys?: string | undefined, logs?: boolean | undefined, stream?: boolean | undefined, stdin?: boolean | undefined, stdout?: boolean | undefined, stderr?: boolean | undefined}; export type CreateApiContainersIdAttachOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Attach to a container * * POST /containers/{id}/attach */ export const createApiContainersIdAttach = async (args: CreateApiContainersIdAttachArgs, options: CreateApiContainersIdAttachOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.detachKeys != null) query.append("detachKeys", String(args.detachKeys)) if (args.logs != null) query.append("logs", String(args.logs)) if (args.stream != null) query.append("stream", String(args.stream)) if (args.stdin != null) query.append("stdin", String(args.stdin)) if (args.stdout != null) query.append("stdout", String(args.stdout)) if (args.stderr != null) query.append("stderr", String(args.stderr)) const url = `${baseUrl.replace(/\/+$/, '')}/containers/${encodeURIComponent(String(args.id))}/attach${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };