How to pull out specific values from Python Script output

Using the SailPoint python plugin v1.05. Here is my script I am running.

search = Search()
    search.indices = ['identities']
    search.query = {'query': '*'}
    search.sort = ['-name']
    identityCount = 0
    accountCount = 0
    workgroupCount = 0

    identities = Paginator.paginate_search(sailpoint.v3.SearchApi(api_client), search, 2, 2)
    for identity in identities:
        pprint(identity['name'])
        # print(identity)
        identityCount = identityCount + 1

    print("Total Identities: " + str(identityCount))

Here is a snippet of the output:
{'id': 'b5239ae9e6b5452898f667f9770de77b', 'name': 'smithk', 'displayName': 'smith', 'firstName': 'Karen', 'lastName': 'Smith', 'email': 'no-email', 'created': '2023-10-18T21:51:34.772Z', 'modified': '2024-06-14T14:46:36.560Z', 'inactive': False, 'protected': False, 'status': 'UNREGISTERED', 'employeeNumber': '11111', 'isManager': False, 'identityProfile': {'id': 'af64a436fa3c4ce5b036c415ca3fe66b', 'name': 'Userdatabase Dev'}, 'source': {'id': '0945e35866c04ccb72a9c42c69a21bf', 'name': 'Userdatabase Dev'}

I know I can use pprint(identity['name']) to get the value of smithk. How would I format it so that I could pull out the ‘identityProfile’ value of Userdatabase Dev or whatever that value would be?

Hi @ScottTanselle,

try with identity[‘identityProfile’][‘name’]

1 Like

Thank you Emanuele, that worked.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.