Python Script to find Connections of a Specific User, Group

premc
premc Partner, Registered Posts: 1 Partner

I Have tried Writing down a Script to find out the connections of a User or a specific group in a Dataiku instance. I Could either find out the user Groups in which he is present but couldn't make it to the point to extract the specific connections of this group/user in that Instance.


Operating system used: Windows

Tagged:

Answers

  • Tomas
    Tomas Registered, Neuron 2022 Posts: 121 ✭✭✭✭✭
    edited July 17

    Hi, this should give you the relations between users and user groups.

    import dataiku
    client = dataiku.api_client()
    for user in client.list_users():
    print(user['login'], ','.join(user.get('groups' ,[])))

    Not sure what you mean by connection - if you need to list all the granted Connections in DSS for the particular user you may try:

    import dataiku
    client = dataiku.api_client()
    connections = client.list_connections()
    def is_allowed_to_use(user_groups):
    result = []
    for con, condef in connections.items():
    for g in user_groups:
    if g in condef['allowedGroups']:
    result.append(con)
    return result
    for user in client.list_users():
    user_groups = user.get('groups' ,[])
    print(user['login'], ','.join(user_groups), is_allowed_to_use(user_groups))
Setup Info
    Tags
      Help me…