add bill-detail file

This commit is contained in:
zhengjiajie
2018-12-11 16:29:50 +08:00
parent 89527c7b69
commit beec785040
2 changed files with 61 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
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 BillDetailListOptions struct {
options.BaseListOptions
STARTDATE string `"help":"start date of the bill_detail"`
ENDDATE string `"help":"end date of the bill_detail"`
ProjectId string `"help":"project id of the bill_detail"`
}
R(&BillDetailListOptions{}, "billdetail-list", "List all bill details", func(s *mcclient.ClientSession, args *BillDetailListOptions) error {
var params *jsonutils.JSONDict
{
var err error
params, err = args.BaseListOptions.Params()
if err != nil {
return err
}
}
if len(args.STARTDATE) > 0 {
params.Add(jsonutils.NewString(args.STARTDATE), "start_date")
}
if len(args.ENDDATE) > 0 {
params.Add(jsonutils.NewString(args.ENDDATE), "end_date")
}
if len(args.ProjectId) > 0 {
params.Add(jsonutils.NewString(args.ProjectId), "project_id")
}
result, err := modules.BillDetails.List(s, params)
if err != nil {
return err
}
printList(result, modules.BillDetails.GetColumns(s))
return nil
})
}
+14
View File
@@ -0,0 +1,14 @@
package modules
var (
BillDetails ResourceManager
)
func init() {
BillDetails = NewMeterManager("bill_detail", "bill_details",
[]string{"bill_id", "account", "platform", "region", "sub_account_project", "res_id",
"res_type", "res_name", "start_time", "end_time", "charge_type", "item_rate", "item_fee"},
[]string{},
)
register(&BillDetails)
}