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

c7n.report - add raw output option #3692

Merged
merged 4 commits into from Mar 18, 2019

Conversation

ericforbes
Copy link
Contributor

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.

Copy link
Collaborator

@kapilt kapilt left a 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?

for record in arr:
for k in record.copy():
if k == "CustodianDate":
del record[k]
Copy link
Collaborator

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

@ericforbes
Copy link
Contributor Author

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?

@kapilt
Copy link
Collaborator

kapilt commented Mar 18, 2019

its a utility function we define in c7n, see from c7n.utils import dumps

@kapilt
Copy link
Collaborator

kapilt commented Mar 18, 2019

lgtm, the only question remaining is name it json or raw .. i kinda of favor json if only because its descriptive of what you'll get.. raw feels appropriate but is a little less descriptive of the output and concievably (or maybe not), some provider might actually have a different format, or we might allow blob encoding in a different format (bson, capnproto, zstd compress, etc).

@ericforbes
Copy link
Contributor Author

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

Copy link
Collaborator

@kapilt kapilt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@kapilt kapilt merged commit cfe6eec into cloud-custodian:master Mar 18, 2019
@ericforbes ericforbes deleted the raw_report branch March 18, 2019 20:10
Dkhanas pushed a commit to mediapills/cloud-custodian that referenced this pull request Mar 22, 2019
lamyanba pushed a commit to lamyanba/cloud-custodian that referenced this pull request Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants