awsume icon indicating copy to clipboard operation
awsume copied to clipboard

Add option to list profiles in JSON

Open okelet opened this issue 5 years ago • 2 comments

In order to use the awsumepy library from scripts, when running this code:

awsumepy.awsume('profile', '-l')

It prints out the list of profile in a non-friendly parseable format in the stdout. It would be great that the function could return that information in JSON o dict, instead of printing the data in the stdout and returning None, or in order to capture the command output and parse the stdout.

okelet avatar Oct 07 '20 11:10 okelet

Happy holidays!

Support for getting profile data as a dict has been released in the latest pre-release (currently awsume==4.5.1a2).

exceptions.EarlyExit has been updated to allow returning data to the non-interactive caller, and the list profiles handler has been updated to send the profile data back (and also not print the profile information when called non-interactively). This means that you should be able to do this:

from awsume.awsumepy import awsume
data = awsume('-l')
print(data['profiles'])

Let me know if there are any bugs, thank you!

mbarneyjr avatar Dec 27 '20 01:12 mbarneyjr

4.5.1 has been released that returns the profile dictionary to non-interacitve calls of awsume (via python import)

We're working on being able to output the profile listing as json from the CLI (awsume -l | jq ...), so we'll leave this issue open until we get that released

Thanks!

mbarneyjr avatar May 11 '21 15:05 mbarneyjr