Edits history of script submission #22660 for ' List SQL Warehouses (databricks)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * List SQL Warehouses
     * List all SQL warehouses in the workspace, including their state and size.
     */
    export async function main(auth: RT.Databricks) {
      const base = auth.workspace_url.replace(/\/$/, "")
      const url = new URL(`${base}/api/2.0/sql/warehouses`)
    
      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 5 days ago