need a script to find project key, project owner and group name under permission tab

Options
SAURABH
SAURABH Partner, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Core Concepts, Dataiku DSS Adv Designer, Registered Posts: 26 Partner

can someone please suggest i have created the below script ,but using it i am only able to find the project name and project owner only for groups under permission it says

Script :

import dataiku
client = dataiku.api_client()
project_list = client.list_project_keys()
for projects in project_list:
dssproject = client.get_project(projects)
perm = dssproject.get_permissions()
owner_name = perm['owner']
group = perm['group']
print (projects+',', owner_name +',',group)

Error :

KeyError Traceback (most recent call last)
<ipython-input-23-85bbf5c840f7> in <module>
6 perm = dssproject.get_permissions()
7 owner_name = perm['owner']
----> 8 group = perm['group']
9 print (projects+',', owner_name +',',group)

KeyError: 'group'

can someone please suggest me the proper key or the proper script to fetch the groups under permission tab


Operating system used: LINUX ON PREM

Best Answer

  • Miguel Angel
    Miguel Angel Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 118 Dataiker
    Answer ✓
    Options

    Hi,

    I see you mean the project permissions, not the owner permissions. Thanks for the clarification.

    In that case, in your original script the error was the dictionary used. You need to use ‘dssproject.get_permissions()["permissions”]’

    The output will have the following format:

    Screenshot 2022-11-10 at 16.41.35.png

Answers

  • Miguel Angel
    Miguel Angel Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 118 Dataiker
    Options

    Hi Saurabh,

    Information about user groups will not be found among the project’s API methods. Instead we need to look into the users and groups API: https://doc.dataiku.com/dss/latest/python-api/users-groups.html#users-and-groups

    This way we can query for each project owner which groups they belong to. For example (Depending on your DSS version the exact syntax may vary):

    import dataiku
    client=dataiku.api_client()
    project_list=client.list_project_keys()
    for projects in project_list:
    dssproject = client.get_project(projects)
    project_owner=dssproject.get_permissions()['owner']
    user_groups = client.get_user(project_owner).get_settings().get_raw()['groups']
    print("Project id: ",projects)
    print("Project owner: ",project_owner)
    print("Owner groups: ", user_groups)

  • SAURABH
    SAURABH Partner, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Core Concepts, Dataiku DSS Adv Designer, Registered Posts: 26 Partner
    Options

    @MiguelangelC
    thank you for the script

    But i am not looking for the groups to which project owner is tagged but i am looking for the groups under the permission tab reference screenshot attached

Setup Info
    Tags
      Help me…