Skip to content

Commit 61d3d79

Browse files
direct: Add permissions support for dashboards
1 parent f350081 commit 61d3d79

File tree

14 files changed

+245
-8
lines changed

14 files changed

+245
-8
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
resources:
2+
dashboards:
3+
foo:
4+
display_name: test-dashboard
5+
warehouse_id: 123abc
6+
parent_path: /Users/tester@databricks.com
7+
serialized_dashboard: '{"pages":[{"name":"page1","displayName":"Page 1"}]}'
8+
permissions:
9+
- level: CAN_READ
10+
user_name: viewer@example.com
11+
- level: CAN_MANAGE
12+
group_name: data-team
13+
- level: CAN_MANAGE
14+
service_principal_name: f37d18cd-98a8-4db5-8112-12dd0a6bfe38
15+
- level: CAN_MANAGE
16+
user_name: tester@databricks.com
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"plan": {
3+
"resources.dashboards.foo": {
4+
"action": "create",
5+
"new_state": {
6+
"config": {
7+
"display_name": "test-dashboard",
8+
"parent_path": "/Users/[USERNAME]",
9+
"warehouse_id": "123abc"
10+
}
11+
}
12+
},
13+
"resources.dashboards.foo.permissions": {
14+
"depends_on": [
15+
{
16+
"node": "resources.dashboards.foo",
17+
"label": "${resources.dashboards.foo.id}"
18+
}
19+
],
20+
"action": "create",
21+
"new_state": {
22+
"config": {
23+
"object_id": "",
24+
"permissions": [
25+
{
26+
"permission_level": "CAN_READ",
27+
"user_name": "viewer@example.com"
28+
},
29+
{
30+
"group_name": "data-team",
31+
"permission_level": "CAN_MANAGE"
32+
},
33+
{
34+
"permission_level": "CAN_MANAGE",
35+
"service_principal_name": "[UUID]"
36+
},
37+
{
38+
"permission_level": "CAN_MANAGE",
39+
"user_name": "[USERNAME]"
40+
}
41+
]
42+
},
43+
"vars": {
44+
"object_id": "/dashboards/${resources.dashboards.foo.id}"
45+
}
46+
}
47+
}
48+
}
49+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"plan": {
3+
"resources.dashboards.foo": {
4+
"action": "create"
5+
}
6+
}
7+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"method": "PUT",
3+
"path": "/api/2.0/permissions/dashboards/[DASHBOARD_ID]",
4+
"body": {
5+
"access_control_list": [
6+
{
7+
"permission_level": "CAN_READ",
8+
"user_name": "viewer@example.com"
9+
},
10+
{
11+
"group_name": "data-team",
12+
"permission_level": "CAN_MANAGE"
13+
},
14+
{
15+
"permission_level": "CAN_MANAGE",
16+
"service_principal_name": "[UUID]"
17+
},
18+
{
19+
"permission_level": "CAN_MANAGE",
20+
"user_name": "[USERNAME]"
21+
}
22+
]
23+
}
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"method": "PUT",
3+
"path": "/api/2.0/permissions/dashboards/[DASHBOARD_ID]",
4+
"body": {
5+
"access_control_list": [
6+
{
7+
"permission_level": "CAN_READ",
8+
"user_name": "viewer@example.com"
9+
},
10+
{
11+
"permission_level": "CAN_MANAGE",
12+
"service_principal_name": "[UUID]"
13+
},
14+
{
15+
"group_name": "data-team",
16+
"permission_level": "CAN_MANAGE"
17+
},
18+
{
19+
"permission_level": "CAN_MANAGE",
20+
"user_name": "[USERNAME]"
21+
}
22+
]
23+
}
24+
}

acceptance/bundle/resources/permissions/dashboards/create/out.requests.destroy.direct.json

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"method": "PUT",
3+
"path": "/api/2.0/permissions/dashboards/[DASHBOARD_ID]",
4+
"body": {}
5+
}

acceptance/bundle/resources/permissions/dashboards/create/out.test.toml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
>>> [CLI] bundle validate -o json
3+
[
4+
{
5+
"level": "CAN_READ",
6+
"user_name": "viewer@example.com"
7+
},
8+
{
9+
"group_name": "data-team",
10+
"level": "CAN_MANAGE"
11+
},
12+
{
13+
"level": "CAN_MANAGE",
14+
"service_principal_name": "[UUID]"
15+
},
16+
{
17+
"level": "CAN_MANAGE",
18+
"user_name": "[USERNAME]"
19+
}
20+
]
21+
22+
>>> [CLI] bundle deploy
23+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
24+
Deploying resources...
25+
Updating deployment state...
26+
Deployment complete!
27+
28+
>>> [CLI] bundle destroy --auto-approve
29+
The following resources will be deleted:
30+
delete dashboard foo
31+
32+
All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle/default
33+
34+
Deleting files...
35+
Destroy complete!
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
trace $CLI bundle validate -o json | jq .resources.$RESOURCE.foo.permissions
2+
rm out.requests.txt
3+
4+
$CLI bundle debug plan > out.plan.$DATABRICKS_BUNDLE_ENGINE.json
5+
6+
print_requests() {
7+
jq -c < out.requests.txt | jq 'select(.method != "GET" and (.path | contains("permissions")))'
8+
rm out.requests.txt
9+
}
10+
11+
rm out.requests.txt
12+
trace $CLI bundle deploy
13+
14+
dashboard_id=$($CLI bundle summary --output json | jq -r '.resources.dashboards.foo.id')
15+
echo "$dashboard_id:DASHBOARD_ID" >> ACC_REPLS
16+
17+
print_requests > out.requests.deploy.$DATABRICKS_BUNDLE_ENGINE.json
18+
19+
trace $CLI bundle destroy --auto-approve
20+
print_requests > out.requests.destroy.$DATABRICKS_BUNDLE_ENGINE.json

0 commit comments

Comments
 (0)