mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #728 in YUNIONIO/onecloud from ~ZHENGJIAJIE/onecloud:feature/add-bill-detail-api to release/2.4.0
* commit '31cb423a2f8442a1385a6f0c87e4a0bec4062e74': zhengjj add files
This commit is contained in:
@@ -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 BillResourceListOptions struct {
|
||||
options.BaseListOptions
|
||||
STARTDATE string `help:"start date of the bill_resource"`
|
||||
ENDDATE string `help:"end date of the bill_resource"`
|
||||
ProjectId string `help:"project id of the bill_resource"`
|
||||
}
|
||||
R(&BillResourceListOptions{}, "billresource-list", "List all bill resources", func(s *mcclient.ClientSession, args *BillResourceListOptions) 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.BillResources.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printList(result, modules.BillResources.GetColumns(s))
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -6,7 +6,7 @@ var (
|
||||
|
||||
func init() {
|
||||
BillDetails = NewMeterManager("bill_detail", "bill_details",
|
||||
[]string{"bill_id", "account", "platform", "region", "sub_account_project", "res_id",
|
||||
[]string{"bill_id", "account", "platform", "region", "manager_project", "res_id",
|
||||
"res_type", "res_name", "start_time", "end_time", "charge_type", "item_rate", "item_fee"},
|
||||
[]string{},
|
||||
)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package modules
|
||||
|
||||
var (
|
||||
BillResources ResourceManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
BillResources = NewMeterManager("bill_resource", "bill_resources",
|
||||
[]string{"account", "platform", "region", "manager_project", "res_id",
|
||||
"res_type", "res_name", "charge_type", "res_fee"},
|
||||
[]string{},
|
||||
)
|
||||
register(&BillResources)
|
||||
}
|
||||
Reference in New Issue
Block a user