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

Tomas
Tomas Registered, Neuron 2022 Posts: 121 ✭✭✭✭✭
Would it be possible to add a code sample for setting (granting) permissions on projects for a specific group into the documentation?

Thanks
Tagged:

Answers

  • Liev
    Liev Dataiker Alumni Posts: 176 ✭✭✭✭✭✭✭✭
    edited July 18

    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!

  • falkmatt
    falkmatt Registered Posts: 1 ✭✭✭

    Hi team,

    does such a code snippet also exist for instance level permissions, such as described here in the documentation? The background is that I want to automate group level permissions when creating a DSS instance.

    Thanks in advance!

Setup Info
    Tags
      Help me…