Community Conundrums are live! Learn more

Code sample for setting (granting) permissions on projects for a specific group

Level 4
Code sample for setting (granting) permissions on projects for a specific group
Would it be possible to add a code sample for setting (granting) permissions on projects for a specific group into the documentation?

Thanks
0 Kudos
1 Reply
Dataiker
Dataiker

Hi tomas, 



Here's an example of how this might work, the name of groups and projects is for illustration purposes.




# setting client and loading project
client = dataiku.api_client()
project = client.get_project("PROJECT_KEY")

# set new group as readers
project_permissions = project.get_permissions()
project_permissions['permissions'] = [{'group':'kaggle','readProjectContent': True}]
project.set_permissions(project_permissions)

# set another group as admin, while leaving first as readers
project_permissions = project.get_permissions()
project_permissions['permissions'] = [{'group':'kaggle','readProjectContent': True}, {'group':'recommenders','admin': True}]
project.set_permissions(project_permissions)

# set first group to admin, while removing the second one altogether
project_permissions = project.get_permissions()
project_permissions['permissions'] = [{'group':'kaggle','admin': True}]
project.set_permissions(project_permissions)


I hope this helps!



 

0 Kudos
Labels (2)