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