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

support credit refunds in billing report #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shaneknapp
Copy link
Contributor

i sure do wish there was a better way to do this, other than scanning for a text pattern in a field... apparently there's no documented code i can find right now that will do this.

i won't merge until after i spend more time digging to see if there's a better way. :\

@jey
Copy link

jey commented Nov 2, 2018

meh, looks pretty reasonable to me. maybe you can parse the row objects into a namedtuple to make the code easier to read?

i think the official field names are available here: https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/enhanced-lineitem-columns.html

for row in billing_data:
if len(row) < 4:
continue
if row[3] == 'LinkedLineItem' and 'Unauthorized Usage' in row[18]:
Copy link

Choose a reason for hiding this comment

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

'Unauthorized Usage' in row[18]

might want to use a stricter test than just a substring check, since it's better for the script to error out if the format of the field changes, which serves as a notice to update the code for the new changes

@shaneknapp
Copy link
Contributor Author

re: namedtuple... sure thing.

re: list of lineitem types... i found that exact page, but none of those fields actually show up in the detailed billing report. hence my sad 'Unauthorized Usage' in row[18] hack. :(

re: stricter parsing, sounds good to me.

@jey
Copy link

jey commented Nov 6, 2018

Hm, the way I'm reading it, I think that row[18] should be the 19th entry on that page, which is "lineItem/UsageType"? So with the namedtuple maybe it would end up looking like row.usage_type.startswith("Unauthorized Usage")?

@shaneknapp
Copy link
Contributor Author

btw i haven't forgotten about this... more commits coming this week.

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.

2 participants