Discover all of the brand-new features and improvements to existing capabilities in the Dataiku 11.3 updateLET'S GO

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

Solved!
saurabh
Level 2
need a script to find project key, project owner and group name under permission tab

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

0 Kudos
1 Solution
MiguelangelC
Dataiker

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

 

 

View solution in original post

0 Kudos
3 Replies
MiguelangelC
Dataiker

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)

0 Kudos
saurabh
Level 2
Author

@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 

0 Kudos
MiguelangelC
Dataiker

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

 

 

0 Kudos