1 |
|
2 | * get job updates |
3 | * |
4 | */ |
5 | export async function main( |
6 | workspace: string, |
7 | id: string, |
8 | running: string | undefined, |
9 | log_offset: string | undefined |
10 | ) { |
11 | const url = new URL(`${BASE_URL}/api/w/${workspace}/jobs_u/getupdate/${id}`); |
12 | for (const [k, v] of [ |
13 | ["running", running], |
14 | ["log_offset", log_offset], |
15 | ]) { |
16 | if (v !== undefined && v !== "") { |
17 | url.searchParams.append(k, v); |
18 | } |
19 | } |
20 | const response = await fetch(url, { |
21 | method: "GET", |
22 | headers: { |
23 | Authorization: "Bearer " + WM_TOKEN, |
24 | }, |
25 | body: undefined, |
26 | }); |
27 | if (!response.ok) { |
28 | const text = await response.text(); |
29 | throw new Error(`${response.status} ${text}`); |
30 | } |
31 | return await response.json(); |
32 | } |
33 |
|