export type GetApiContainersIdLogsArgs = {id: string, follow?: boolean | undefined, stdout?: boolean | undefined, stderr?: boolean | undefined, since?: number | undefined, until?: number | undefined, timestamps?: boolean | undefined, tail?: string | undefined}; export type GetApiContainersIdLogsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Get container logs * * GET /containers/{id}/logs */ export const getApiContainersIdLogs = async (args: GetApiContainersIdLogsArgs, options: GetApiContainersIdLogsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/vnd.docker.raw-stream") if (args.follow != null) query.append("follow", String(args.follow)) if (args.stdout != null) query.append("stdout", String(args.stdout)) if (args.stderr != null) query.append("stderr", String(args.stderr)) if (args.since != null) query.append("since", String(args.since)) if (args.until != null) query.append("until", String(args.until)) if (args.timestamps != null) query.append("timestamps", String(args.timestamps)) if (args.tail != null) query.append("tail", String(args.tail)) const url = `${baseUrl.replace(/\/+$/, '')}/containers/${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.blob() };