Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to list profiles in JSON #123

Open
okelet opened this issue Oct 7, 2020 · 2 comments
Open

Add option to list profiles in JSON #123

okelet opened this issue Oct 7, 2020 · 2 comments

Comments

@okelet
Copy link

okelet commented Oct 7, 2020

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.

@mbarneyjr
Copy link
Member

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
Copy link
Member

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants