sbg / sevenbridges-python

SevenBridges Python Api bindings
Apache License 2.0
46 stars 28 forks source link

billing breakdown invalid #124

Open boyangzhao opened 3 years ago

boyangzhao commented 3 years ago

sevenbridges-python: 2.5.0

I'm using the api to calling the billing group method, but it seems breakdown() is not working (previously it was). Upon calling the breakdown() method, I receive the following error (I replaced actual billing group with \<billing group>)

sevenbridges.errors.NotFound: /v2/billing/groups/<billing group>/breakdown not found

bogdang989 commented 3 years ago

Hi @boyangzhao thank you for opening the issue, and apologies for inconvenience. As you noticed, the breakdown() method is not working and will be deprecated very soon in a new release. The billing breakdowns are available in more detail in three new methods for analysis, storage and egress billing breakdowns, e.g. analysis_breakdown(). Hope this information is helpful, I will close this issue, please reopen if needed.

boyangzhao commented 3 years ago

Thanks - is there an equivalent to get at the total_spending.amount that was previously available in breakdown. The methods (analyses, storage, egress) return arrays and it seems you have to now sum through all the array items and across all the analyses/storage/egress breakdowns to get at the total spending amount.

bogdang989 commented 3 years ago

Hi, you are right for now the only way to get the total is to sum everything up. I will send a ticket internally to see if we can improve this somehow. Thanks again for the feedback.

boyangzhao commented 3 years ago

Thanks that would be great. Also, while egress and analyses as cost fields, storage does not contain cost fields, so I cannot get the total by simply summing it up. Storage seems to have in units of GB/Month, but based on the https://docs.sevenbridges.com/docs/storage-costs example, it doesn't seem though it is adding up. Can you clarify if the unit is indeed GB/Month, and how do we go from size to storage cost?

bogdang989 commented 3 years ago

Hi @boyangzhao This is an oversight, and the unit should actually be GB * Month. I added a recipe here with some explanations https://github.com/sbg/okAPI/blob/master/Recipes/SBPLAT/billing_getTotalForPeriod.ipynb that shows example of how to sum up all costs in a project for a particular time frame, including storage costs.

boyangzhao commented 3 years ago

Thanks - I also saw in the documentations the cost conversions (for example here). But the conversion of $0.023 per (GB month) doesn't quite match that in billing on SB. For example ~ 61000 GBMonth (the sum through the API) would lead to $1400, but in billing, this corresponds to ~$70. This is off by a pretty big factor. Previously the total_spending.amount matches the total spending under billing on SB.

A side note, it seemed the date_from and date_to follows mm-dd-yyyy and not dd-mm-yyyy format