export type GetApiLogsArgs = {project_name?: string | undefined, model_id?: string | undefined, model_name?: string | undefined, version_id?: string | undefined, prediction_job_id?: string | undefined, cluster: string, namespace: string, component_type: 'image_builder' | 'model' | 'transformer' | 'batch_job_driver' | 'batch_job_executor', container_name?: string | undefined, prefix?: string | undefined, follow?: string | undefined, previous?: string | undefined, since_seconds?: string | undefined, since_time?: string | undefined, timestamps?: string | undefined, tail_lines?: string | undefined, limit_bytes?: string | undefined}; export type GetApiLogsOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Retrieve log from a container * * GET /logs */ export const getApiLogs = async (args: GetApiLogsArgs, options?: GetApiLogsOptions) => { const {baseUrl = "http://localhost:8080/v1", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.project_name != null) query.append("project_name", String(args.project_name)) if (args.model_id != null) query.append("model_id", String(args.model_id)) if (args.model_name != null) query.append("model_name", String(args.model_name)) if (args.version_id != null) query.append("version_id", String(args.version_id)) if (args.prediction_job_id != null) query.append("prediction_job_id", String(args.prediction_job_id)) if (args.cluster != null) query.append("cluster", String(args.cluster)) if (args.namespace != null) query.append("namespace", String(args.namespace)) if (args.component_type != null) query.append("component_type", String(args.component_type)) if (args.container_name != null) query.append("container_name", String(args.container_name)) if (args.prefix != null) query.append("prefix", String(args.prefix)) if (args.follow != null) query.append("follow", String(args.follow)) if (args.previous != null) query.append("previous", String(args.previous)) if (args.since_seconds != null) query.append("since_seconds", String(args.since_seconds)) if (args.since_time != null) query.append("since_time", String(args.since_time)) if (args.timestamps != null) query.append("timestamps", String(args.timestamps)) if (args.tail_lines != null) query.append("tail_lines", String(args.tail_lines)) if (args.limit_bytes != null) query.append("limit_bytes", String(args.limit_bytes)) if (Bearer !== undefined) headers.set("Authorization", Bearer) const url = `${baseUrl.replace(/\/+$/, '')}/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 undefined };