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
c7n.report - add raw output option #3692
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pull request. Rather than raw what do you think about 'json' as the name? i think we can simplify the date time removal via just using the std custodian json serializer which handles datetimes. One other question is this returning the actual raw records, or it it just the values that would normally be returned by csv etc formats, ie does --field stuff still apply or is it just the full dump of whatever is found in resources.json?
c7n/reports/csvout.py
Outdated
for record in arr: | ||
for k in record.copy(): | ||
if k == "CustodianDate": | ||
del record[k] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rather than removing the records, we can just just utils.dumps which will do datetime serialization for json on datetime
This returns the raw JSON records with two added keys in the JSON objects: policy (policy name) and region. I'm not familiar and cannot find anything docs about a Utils python class available? I can instead check for CustodianDate and then replace it with date.isoformat() instead of removing it.. thoughts? |
its a utility function we define in c7n, see |
lgtm, the only question remaining is name it |
Yes I agree here.. the format types (csv, grid, simple) describe the type of output, raw doesn't really make sense and JSON does here as it is clear to the user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
c7n.report - add raw output option
Description: This adds
--format raw
option to the c7n report command. Using this will spit out the JSON to standard out. This is useful when we want the raw JSON instead of CSV or some other filtered/sorted output.