Merge pull request #11650 from bistuzx/master

feat(meter): add meter cost conversion
This commit is contained in:
Zexi Li
2021-07-14 18:52:16 +08:00
committed by GitHub
3 changed files with 116 additions and 0 deletions
+29
View File
@@ -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.CostConversions).WithKeyword("cost-conversion")
cmd.List(new(options.CostConversionListOptions))
cmd.Create(new(options.CostConversionCreateOptions))
cmd.Update(new(options.CostConversionUpdateOptions))
cmd.Delete(new(options.CostConversionDeleteOptions))
}
@@ -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 (
CostConversions modulebase.ResourceManager
)
func init() {
CostConversions = NewMeterManager("cost_conversion", "cost_conversions",
[]string{"is_public_cloud", "brand", "cloudaccount_id", "cloudprovider_id", "domain_id_filter", "enable_date", "ratio"},
[]string{},
)
register(&CostConversions)
}
@@ -0,0 +1,58 @@
package meter
import (
"yunion.io/x/jsonutils"
"yunion.io/x/onecloud/pkg/mcclient/options"
)
type CostConversionListOptions struct {
options.BaseListOptions
}
func (opt *CostConversionListOptions) Params() (jsonutils.JSONObject, error) {
return options.StructToParams(opt)
}
type CostConversionCreateOptions struct {
Name string
IsPublicCloud string `help:"public cloud filter of cost conversion" json:"is_public_cloud"`
Brand string `help:"brand filter of cost conversion" json:"brand"`
CloudaccountId string `help:"cloudaccount filter of cost conversion" json:"cloudaccount_id"`
CloudproviderId string `help:"cloudprovider filter of cost conversion" json:"cloudprovider_id"`
DomainIdFilter string `help:"domain filter of cost conversion" json:"domain_id_filter"`
EnableDate string `help:"enable date of conversion ratio, example:202107" json:"ratio"`
Ratio float64 `help:"cost conversion ratio" json:"ratio"`
}
func (opt *CostConversionCreateOptions) Params() (jsonutils.JSONObject, error) {
return options.StructToParams(opt)
}
type CostConversionUpdateOptions struct {
ID string `help:"ID of cost conversion" json:"-"`
Ratio float64 `help:"cost conversion ratio" json:"ratio"`
}
func (opt *CostConversionUpdateOptions) Params() (jsonutils.JSONObject, error) {
return options.StructToParams(opt)
}
func (opt *CostConversionUpdateOptions) GetId() string {
return opt.ID
}
type CostConversionDeleteOptions struct {
ID string `help:"ID of cost conversion" json:"-"`
}
func (opt *CostConversionDeleteOptions) Params() (jsonutils.JSONObject, error) {
return options.StructToParams(opt)
}
func (opt *CostConversionDeleteOptions) GetId() string {
return opt.ID
}