1 | |
2 | * Converts an S3 resource to the set of instructions necessary to connect DuckDB to an S3 bucket |
3 | * |
4 | */ |
5 | export async function main( |
6 | workspace: string, |
7 | body: { s3_resource_path?: string; [k: string]: unknown } |
8 | ) { |
9 | const url = new URL( |
10 | `${BASE_URL}/api/w/${workspace}/job_helpers/v2/duckdb_connection_settings` |
11 | ); |
12 |
|
13 | const response = await fetch(url, { |
14 | method: "POST", |
15 | headers: { |
16 | "Content-Type": "application/json", |
17 | Authorization: "Bearer " + WM_TOKEN, |
18 | }, |
19 | body: JSON.stringify(body), |
20 | }); |
21 | if (!response.ok) { |
22 | const text = await response.text(); |
23 | throw new Error(`${response.status} ${text}`); |
24 | } |
25 | return await response.json(); |
26 | } |
27 |
|