Skip to content

Commit 97b92e1

Browse files
committed
Added Databricks SQL Warehouses API actions
- Added create SQL warehouse action - Added list SQL warehouses action - Added get SQL warehouse action - Added edit SQL warehouse action - Added delete SQL warehouse action - Added start/stop SQL warehouse actions - Added get/set SQL warehouse config actions - Added get/set SQL warehouse permissions actions Implements 11 SQL Warehouses endpoints as discussed in the enhancement issue.
1 parent 4601f6f commit 97b92e1

File tree

12 files changed

+399
-0
lines changed

12 files changed

+399
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import databricks from "../../databricks.app.mjs";
2+
3+
export default {
4+
key: "databricks-create-sql-warehouse",
5+
name: "Create SQL Warehouse",
6+
description: "Creates a new SQL Warehouse in Databricks. [See the documentation](https://docs.databricks.com/api/workspace/warehouse/create)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
databricks,
11+
name: {
12+
type: "string",
13+
label: "Warehouse Name",
14+
description: "A human-readable name for the warehouse",
15+
},
16+
clusterSize: {
17+
type: "string",
18+
label: "Cluster Size",
19+
description: "Size of the cluster (e.g., `Small`, `Medium`, `Large`)",
20+
},
21+
autoStopMinutes: {
22+
type: "integer",
23+
label: "Auto Stop (minutes)",
24+
description: "Number of minutes of inactivity before the warehouse auto-stops",
25+
optional: true,
26+
default: 10,
27+
},
28+
},
29+
async run({ $ }) {
30+
const payload = {
31+
name: this.name,
32+
cluster_size: this.clusterSize,
33+
auto_stop_mins: this.autoStopMinutes,
34+
};
35+
36+
const response = await this.databricks.createSQLWarehouse({
37+
data: payload,
38+
$,
39+
});
40+
41+
$.export("$summary", `Successfully created SQL Warehouse: ${response?.name || this.name}`);
42+
return response;
43+
},
44+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import databricks from "../../databricks.app.mjs";
2+
3+
export default {
4+
key: "databricks-delete-sql-warehouse",
5+
name: "Delete SQL Warehouse",
6+
description: "Deletes a SQL Warehouse by ID. [See the documentation](https://docs.databricks.com/api/workspace/warehouse/delete)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
databricks,
11+
warehouseId: {
12+
type: "string",
13+
label: "Warehouse ID",
14+
description: "The ID of the SQL Warehouse to delete",
15+
},
16+
},
17+
async run({ $ }) {
18+
await this.databricks.deleteSQLWarehouse({
19+
warehouseId: this.warehouseId,
20+
$,
21+
});
22+
23+
$.export("$summary", `Successfully deleted SQL Warehouse with ID ${this.warehouseId}`);
24+
return { success: true };
25+
},
26+
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import databricks from "../../databricks.app.mjs";
2+
3+
export default {
4+
key: "databricks-edit-sql-warehouse",
5+
name: "Edit SQL Warehouse",
6+
description: "Edits the configuration of an existing SQL Warehouse. [See docs](https://docs.databricks.com/api/workspace/warehouse/edit)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
databricks,
11+
warehouseId: {
12+
type: "string",
13+
label: "Warehouse ID",
14+
description: "The ID of the SQL Warehouse to edit",
15+
},
16+
body: {
17+
type: "object",
18+
label: "Edit Configuration",
19+
description: "The new configuration for the SQL Warehouse (JSON object). Example: `{ \"name\": \"Updated Warehouse\", \"cluster_size\": \"2X-Small\" }`",
20+
},
21+
},
22+
async run({ $ }) {
23+
const response = await this.databricks.editSQLWarehouse({
24+
warehouseId: this.warehouseId,
25+
data: this.body,
26+
$,
27+
});
28+
29+
$.export("$summary", `Successfully edited SQL Warehouse ID ${this.warehouseId}`);
30+
return response;
31+
},
32+
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import databricks from "../../databricks.app.mjs";
2+
3+
export default {
4+
key: "databricks-get-sql-warehouse-config",
5+
name: "Get SQL Warehouse Config",
6+
description: "Retrieves the global configuration for SQL Warehouses. [See docs](https://docs.databricks.com/api/workspace/warehouse/get-config)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
databricks,
11+
},
12+
async run({ $ }) {
13+
const response = await this.databricks.getSQLWarehouseConfig({ $ });
14+
$.export("$summary", "Successfully retrieved SQL Warehouse configuration");
15+
return response;
16+
},
17+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import databricks from "../../databricks.app.mjs";
2+
3+
export default {
4+
key: "databricks-get-sql-warehouse-permissions",
5+
name: "Get SQL Warehouse Permissions",
6+
description: "Retrieves the permissions for a specific SQL Warehouse. [See docs](https://docs.databricks.com/api/workspace/warehouse/get-permissions)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
databricks,
11+
warehouseId: {
12+
type: "string",
13+
label: "Warehouse ID",
14+
description: "The ID of the SQL Warehouse to fetch permissions for",
15+
},
16+
},
17+
async run({ $ }) {
18+
const response = await this.databricks.getSQLWarehousePermissions({
19+
warehouseId: this.warehouseId,
20+
$,
21+
});
22+
23+
$.export("$summary", `Retrieved permissions for SQL Warehouse ID ${this.warehouseId}`);
24+
return response;
25+
},
26+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import databricks from "../../databricks.app.mjs";
2+
3+
export default {
4+
key: "databricks-get-sql-warehouse",
5+
name: "Get SQL Warehouse",
6+
description: "Retrieves details for a specific SQL Warehouse. [See docs](https://docs.databricks.com/api/workspace/warehouse/get)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
databricks,
11+
warehouseId: {
12+
type: "string",
13+
label: "Warehouse ID",
14+
description: "The ID of the SQL Warehouse to retrieve",
15+
},
16+
},
17+
async run({ $ }) {
18+
const response = await this.databricks.getSQLWarehouse({
19+
warehouseId: this.warehouseId,
20+
$,
21+
});
22+
23+
$.export("$summary", `Retrieved details for SQL Warehouse ID ${this.warehouseId}`);
24+
return response;
25+
},
26+
};
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import databricks from "../../databricks.app.mjs";
2+
3+
export default {
4+
key: "databricks-list-sql-warehouses",
5+
name: "List SQL Warehouses",
6+
description: "Lists all SQL Warehouses available in the Databricks workspace. [See the documentation](https://docs.databricks.com/api/workspace/warehouse/list)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
databricks,
11+
maxResults: {
12+
type: "integer",
13+
label: "Max Results",
14+
description: "Maximum number of warehouses to return",
15+
default: 50,
16+
optional: true,
17+
},
18+
},
19+
async run({ $ }) {
20+
const params = {
21+
limit: this.maxResults || 50,
22+
};
23+
24+
const { warehouses } = await this.databricks.listSQLWarehouses({
25+
params,
26+
$,
27+
});
28+
29+
if (!warehouses?.length) {
30+
$.export("$summary", "No warehouses found.");
31+
return [];
32+
}
33+
34+
$.export("$summary", `Successfully retrieved ${warehouses.length} warehouse${warehouses.length === 1 ? "" : "s"}.`);
35+
36+
return warehouses;
37+
},
38+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import databricks from "../../databricks.app.mjs";
2+
3+
export default {
4+
key: "databricks-set-sql-warehouse-config",
5+
name: "Set SQL Warehouse Config",
6+
description: "Updates the global configuration for SQL Warehouses. [See docs](https://docs.databricks.com/api/workspace/warehouse/set-config)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
databricks,
11+
config: {
12+
type: "object",
13+
label: "Configuration",
14+
description: "The configuration object for SQL Warehouses. Example: `{ \"enable_serverless_compute\": true }`",
15+
},
16+
},
17+
async run({ $ }) {
18+
const response = await this.databricks.setSQLWarehouseConfig({
19+
data: this.config,
20+
$,
21+
});
22+
23+
$.export("$summary", "Successfully updated SQL Warehouse configuration");
24+
return response;
25+
},
26+
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import databricks from "../../databricks.app.mjs";
2+
3+
export default {
4+
key: "databricks-set-sql-warehouse-permissions",
5+
name: "Set SQL Warehouse Permissions",
6+
description: "Updates the permissions for a specific SQL Warehouse. [See docs](https://docs.databricks.com/api/workspace/warehouse/set-permissions)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
databricks,
11+
warehouseId: {
12+
type: "string",
13+
label: "Warehouse ID",
14+
description: "The ID of the SQL Warehouse to update permissions for",
15+
},
16+
permissions: {
17+
type: "object",
18+
label: "Permissions",
19+
description: "The permissions object. Example: `{ \"access_control_list\": [{ \"user_name\": \"[email protected]\", \"permission_level\": \"CAN_MANAGE\" }] }`",
20+
},
21+
},
22+
async run({ $ }) {
23+
const response = await this.databricks.setSQLWarehousePermissions({
24+
warehouseId: this.warehouseId,
25+
data: this.permissions,
26+
$,
27+
});
28+
29+
$.export("$summary", `Successfully updated permissions for SQL Warehouse ID ${this.warehouseId}`);
30+
return response;
31+
},
32+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import databricks from "../../databricks.app.mjs";
2+
3+
export default {
4+
key: "databricks-start-sql-warehouse",
5+
name: "Start SQL Warehouse",
6+
description: "Starts a SQL Warehouse by ID. [See the documentation](https://docs.databricks.com/api/workspace/warehouse/start)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
databricks,
11+
warehouseId: {
12+
type: "string",
13+
label: "Warehouse ID",
14+
description: "The ID of the SQL Warehouse to start",
15+
},
16+
},
17+
async run({ $ }) {
18+
const response = await this.databricks.startSQLWarehouse({
19+
warehouseId: this.warehouseId,
20+
$,
21+
});
22+
23+
$.export("$summary", `Successfully started SQL Warehouse with ID ${this.warehouseId}`);
24+
return response;
25+
},
26+
};

0 commit comments

Comments
 (0)