//native
/**
* List Workspace
* List the contents (notebooks, folders, files) of a workspace directory. Use "/" for the root.
*/
export async function main(auth: RT.Databricks, path: string) {
const base = auth.workspace_url.replace(/\/$/, "")
const url = new URL(`${base}/api/2.0/workspace/list`)
url.searchParams.append("path", path)
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: `Bearer ${auth.token}`,
Accept: "application/json",
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 6 days ago