1 | |
2 | * run code-workflow task |
3 | * |
4 | */ |
5 | export async function main( |
6 | workspace: string, |
7 | job_id: string, |
8 | entrypoint: string, |
9 | body: { args: { [k: string]: unknown }; [k: string]: unknown } |
10 | ) { |
11 | const url = new URL( |
12 | `${BASE_URL}/api/w/${workspace}/jobs/workflow_as_code/${job_id}/${entrypoint}` |
13 | ); |
14 |
|
15 | const response = await fetch(url, { |
16 | method: "POST", |
17 | headers: { |
18 | "Content-Type": "application/json", |
19 | Authorization: "Bearer " + WM_TOKEN, |
20 | }, |
21 | body: JSON.stringify(body), |
22 | }); |
23 | if (!response.ok) { |
24 | const text = await response.text(); |
25 | throw new Error(`${response.status} ${text}`); |
26 | } |
27 | return await response.text(); |
28 | } |
29 |
|