Merge pull request #780 in YUNIONIO/onecloud from ~ZHENGJIAJIE/onecloud:feature/add-bill-detail-api to release/2.4.0

* commit 'ff3c6eb52623dfc13292e2b5284d9a774224301a':
  zhengjiajie add new files
This commit is contained in:
邱剑
2018-12-18 17:16:09 +08:00
2 changed files with 61 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
package shell
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modules"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
func init() {
type BillBalanceListOptions struct {
options.BaseListOptions
ACCOUNTID string `help:"accountId of the BillBalance"`
}
R(&BillBalanceListOptions{}, "billbalance-list", "List all BillBalances ", func(s *mcclient.ClientSession, args *BillBalanceListOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = args.BaseListOptions.Params()
if err != nil {
return err
}
}
params.Add(jsonutils.NewString(args.ACCOUNTID), "account_id")
result, err := modules.BillBalances.List(s, params)
if err != nil {
return err
}
printList(result, modules.BillBalances.GetColumns(s))
return nil
})
type BillBalanceShowOptions struct {
ACCOUNTID string `help:"accountId of the BillBalance to show"`
}
R(&BillBalanceShowOptions{}, "billbalance-show", "Show BillBalance details", func(s *mcclient.ClientSession, args *BillBalanceShowOptions) error {
result, err := modules.BillBalances.Get(s, args.ACCOUNTID, nil)
if err != nil {
return err
}
printObject(result)
return nil
})
}
+13
View File
@@ -0,0 +1,13 @@
package modules
var (
BillBalances ResourceManager
)
func init() {
BillBalances = NewMeterManager("bill_balance", "bill_balances",
[]string{"provider", "account", "account_name", "query_date", "balance", "currency", "today_fee", "month_fee"},
[]string{},
)
register(&BillBalances)
}