0

List SQL Warehouses

by
Published 4 days ago

List all SQL warehouses in the workspace, including their state and size.

Script databricks Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 5 days ago
1
//native
2

3
/**
4
 * List SQL Warehouses
5
 * List all SQL warehouses in the workspace, including their state and size.
6
 */
7
export async function main(auth: RT.Databricks) {
8
  const base = auth.workspace_url.replace(/\/$/, "")
9
  const url = new URL(`${base}/api/2.0/sql/warehouses`)
10

11
  const response = await fetch(url, {
12
    method: "GET",
13
    headers: {
14
      Authorization: `Bearer ${auth.token}`,
15
      Accept: "application/json",
16
    },
17
  })
18

19
  if (!response.ok) {
20
    throw new Error(`${response.status} ${await response.text()}`)
21
  }
22

23
  return await response.json()
24
}
25