Skip to content

Instantly share code, notes, and snippets.

@ppeiris
Last active November 19, 2019 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ppeiris/27fda75ed9e792d1e73bc1274f157c97 to your computer and use it in GitHub Desktop.
Save ppeiris/27fda75ed9e792d1e73bc1274f157c97 to your computer and use it in GitHub Desktop.
"""
args:
- users
- user_roles
"""
def get_user_roles(self, users, user_roles={}):
for user in users:
if user in user_roles:
continue
self.connection.set_url(f'/api/mo/sys/userext/user-{user}.json?rsp-subtree=full')
self.connection.get()
role = self.connection.get_response_json()
role_name = role['imdata'][0]['aaaUser']
['children'][0]['aaaUserDomain']['children'][0]['aaaUserRole']['attributes']['name']
user_roles.update({user: role_name})
return user_roles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment