diff --git a/cmd/climc/shell/associated_bills.go b/cmd/climc/shell/associated_bills.go new file mode 100644 index 0000000000..e71686a938 --- /dev/null +++ b/cmd/climc/shell/associated_bills.go @@ -0,0 +1,45 @@ +// Copyright 2019 Yunion +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package shell + +import ( + "yunion.io/x/onecloud/pkg/mcclient" + "yunion.io/x/onecloud/pkg/mcclient/modules" + "yunion.io/x/onecloud/pkg/mcclient/options" +) + +func init() { + type AssociatedBillListOptions struct { + options.BaseListOptions + StartDay int `help:"time range of the associated bills, example: 20060102" required:"true"` + EndDay int `help:"time range of the associated bills, example: 20060102" required:"true"` + + ResourceId string `help:"resource id"` + Brand string `help:"brand"` + } + R(&AssociatedBillListOptions{}, "associated-bill-list", "List associated bills", + func(s *mcclient.ClientSession, args *AssociatedBillListOptions) error { + params, err := options.ListStructToParams(args) + if err != nil { + return err + } + result, err := modules.AssociatedBills.List(s, params) + if err != nil { + return err + } + printList(result, modules.AssociatedBills.GetColumns(s)) + return nil + }) +} diff --git a/pkg/mcclient/modules/managers.go b/pkg/mcclient/modules/managers.go index 708da7dd9e..1ebed69cd1 100644 --- a/pkg/mcclient/modules/managers.go +++ b/pkg/mcclient/modules/managers.go @@ -111,7 +111,7 @@ func NewSchedulerManager(keyword, keywordPlural string, columns, adminColumns [] func NewMeterManager(keyword, keywordPlural string, columns, adminColumns []string) modulebase.ResourceManager { return modulebase.ResourceManager{ - BaseManager: *modulebase.NewBaseManager("meter", "", "v1", columns, adminColumns), + BaseManager: *modulebase.NewBaseManager("meter", "", "", columns, adminColumns), Keyword: keyword, KeywordPlural: keywordPlural} } diff --git a/pkg/mcclient/modules/mod_associated_bills.go b/pkg/mcclient/modules/mod_associated_bills.go new file mode 100644 index 0000000000..2c24d4968f --- /dev/null +++ b/pkg/mcclient/modules/mod_associated_bills.go @@ -0,0 +1,29 @@ +// Copyright 2019 Yunion +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package modules + +import "yunion.io/x/onecloud/pkg/mcclient/modulebase" + +var ( + AssociatedBills modulebase.ResourceManager +) + +func init() { + AssociatedBills = NewMeterManager("associated_bill", "associated_bills", + []string{"account", "brand", "resource_id", "resource_name", "amount"}, + []string{}, + ) + register(&AssociatedBills) +}