mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
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:
@@ -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
|
||||
})
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user