Skip to content

Commit d78a7b9

Browse files
committed
adding billing summary
1 parent 9816e83 commit d78a7b9

4 files changed

Lines changed: 39 additions & 1 deletion

File tree

SoftLayer/CLI/billing/info.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ def cli(env):
3333
pass_table = formatting.Table(['Name', 'Value'])
3434
result = info['currency']
3535
for key in result.keys():
36-
print key, result[key]
3736
pass_table.add_row([key, result[key]])
3837
table.add_row(['currency', pass_table])
3938
return table

SoftLayer/CLI/billing/summary.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""List billing summary of Account."""
2+
# :license: MIT, see LICENSE for more details.
3+
4+
5+
import SoftLayer
6+
from SoftLayer.CLI import environment
7+
from SoftLayer.CLI import formatting
8+
9+
import click
10+
11+
12+
@click.command()
13+
@environment.pass_env
14+
def cli(env):
15+
"""List billing details of Account."""
16+
billing = SoftLayer.BillingManager(env.client)
17+
table = formatting.Table(['Name', 'Value'])
18+
balance = billing.get_balance()
19+
next_balance = billing.get_next_balance()
20+
table.add_row(['Current Balance', balance])
21+
table.add_row(['Estimated Next Balance', next_balance])
22+
return table

SoftLayer/CLI/routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
('billing', 'SoftLayer.CLI.billing'),
1111
('billing:list', 'SoftLayer.CLI.billing.list:cli'),
1212
('billing:info', 'SoftLayer.CLI.billing.info:cli'),
13+
('billing:summary', 'SoftLayer.CLI.billing.summary:cli'),
1314

1415
('call-api', 'SoftLayer.CLI.call_api:cli'),
1516

SoftLayer/managers/billing.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,22 @@ def get_info(self):
5858
result = self.account.getBillingInfo()
5959
return result
6060

61+
def get_balance(self):
62+
"""
63+
64+
:return: billing account info
65+
"""
66+
result = self.account.getBalance()
67+
return result
68+
69+
def get_next_balance(self):
70+
"""
71+
72+
:return: billing account info
73+
"""
74+
result = self.account.getNextInvoiceTotalAmount()
75+
return result
76+
6177
def list_resources(self, from_date=None, to_date=None, **kwargs):
6278
""" Retrieve a list of all ordered resources along with their costing.
6379

0 commit comments

Comments
 (0)