Keeper-Security / Commander

Keeper Commander is a python-based CLI and SDK interface to the Keeper Security platform. Provides administrative controls, reporting, import/export and vault management.
https://www.keepersecurity.com/commander.html
MIT License
182 stars 74 forks source link

RecordListCommand() output as a dictionary #1215

Closed BrennanWoodbury closed 3 months ago

BrennanWoodbury commented 3 months ago

I would like to see the output of vault records as a dictionary, like so:

{"uid": "xyz123", "title": "name", "description": "descriptor", "shared": True}

This would be useful as a means to grab UID or other fields programmatically, and pass it into another method for further processing.

I think this can be implemented by building out logic for the kwarg "format" to have an option "dict" through another if block in the RecordListCommand.execute() method.

aaunario-keeper commented 3 months ago

You can convert the output of RecordListCommand to a list of dictionaries (each dictionary corresponding to a vault record) using the format='json' kwarg value....something like the following:

import json
...
records_json = RecordListCommand().execute(params, format='json') # command output as JSON string 
records_list = json.loads(records_json) # list of record dictionaries