mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
add cost report module
This commit is contained in:
@@ -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 meter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||||
|
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||||
|
options "yunion.io/x/onecloud/pkg/mcclient/options/meter"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cmd := shell.NewResourceCmd(&modules.CostReports).WithKeyword("cost-report")
|
||||||
|
cmd.List(new(options.CostReportListOptions))
|
||||||
|
cmd.Create(new(options.CostReportCreateOptions))
|
||||||
|
cmd.Update(new(options.CostReportUpdateOptions))
|
||||||
|
cmd.Delete(new(options.CostReportDeleteOptions))
|
||||||
|
}
|
||||||
@@ -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 (
|
||||||
|
CostReports modulebase.ResourceManager
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
CostReports = NewMeterManager("costreport", "costreports",
|
||||||
|
[]string{"period_type", "day", "colon_timer", "disable", "emails", "scope", "start_run"},
|
||||||
|
[]string{},
|
||||||
|
)
|
||||||
|
register(&CostReports)
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package meter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"yunion.io/x/jsonutils"
|
||||||
|
|
||||||
|
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CostReportListOptions struct {
|
||||||
|
options.BaseListOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
func (opt *CostReportListOptions) Params() (jsonutils.JSONObject, error) {
|
||||||
|
return options.StructToParams(opt)
|
||||||
|
}
|
||||||
|
|
||||||
|
type CostReportCreateOptions struct {
|
||||||
|
Scope string `help:"scope of cost report" json:"scope"`
|
||||||
|
|
||||||
|
PeriodType string `help:"period of cost report send, example:"month/week/day" json:"period_type"`
|
||||||
|
Day int `help:"day of cost report send" json:"day"`
|
||||||
|
ColonTimer string `help:"hour and minute of cost report send, example:"HH:mm" json:"colon_timer"`
|
||||||
|
Emails []string `help:"emails of cost report send" json:"emails"`
|
||||||
|
StartRun bool `help:"whether cost report sends instantly" json:"start_run"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (opt *CostReportCreateOptions) Params() (jsonutils.JSONObject, error) {
|
||||||
|
return options.StructToParams(opt)
|
||||||
|
}
|
||||||
|
|
||||||
|
type CostReportUpdateOptions struct {
|
||||||
|
ID string `help:"ID of cost report" json:"-"`
|
||||||
|
|
||||||
|
PeriodType string `help:"period of cost report send, example:"month/week/day" json:"period_type"`
|
||||||
|
Day int `help:"day of cost report send" json:"day"`
|
||||||
|
ColonTimer string `help:"hour and minute of cost report send, example:"HH:mm" json:"colon_timer"`
|
||||||
|
Emails []string `help:"emails of cost report send" json:"emails"`
|
||||||
|
StartRun bool `help:"whether cost report sends instantly" json:"start_run"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (opt *CostReportUpdateOptions) Params() (jsonutils.JSONObject, error) {
|
||||||
|
return options.StructToParams(opt)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (opt *CostReportUpdateOptions) GetId() string {
|
||||||
|
return opt.ID
|
||||||
|
}
|
||||||
|
|
||||||
|
type CostReportDeleteOptions struct {
|
||||||
|
ID string `help:"ID of cost report" json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (opt *CostReportDeleteOptions) Params() (jsonutils.JSONObject, error) {
|
||||||
|
return options.StructToParams(opt)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (opt *CostReportDeleteOptions) GetId() string {
|
||||||
|
return opt.ID
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user