forked from huaweicloud/huaweicloud-sdk-go-v3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
model_resource_price.go
81 lines (63 loc) · 1.75 KB
/
model_resource_price.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package model
import (
"github.com/dysodeng/huaweicloud-sdk-go-v3/core/utils"
"errors"
"github.com/dysodeng/huaweicloud-sdk-go-v3/core/converter"
"strings"
)
type ResourcePrice struct {
// cpu架构 x86|arm
Arch *ResourcePriceArch `json:"arch,omitempty"`
// 价格
Price *float32 `json:"price,omitempty"`
// 规格。 类型为'storage'时,size值可以为5GB,10GB,20GB。 类型为'cpuMemory'时,arch为'x86',size值可以为1U1G,2U4G,4U8G;arch为'arm',size值可以为4U8G。
Size *string `json:"size,omitempty"`
// 类型。目前可以取值storage,cpuMemory
Type *string `json:"type,omitempty"`
}
func (o ResourcePrice) String() string {
data, err := utils.Marshal(o)
if err != nil {
return "ResourcePrice struct{}"
}
return strings.Join([]string{"ResourcePrice", string(data)}, " ")
}
type ResourcePriceArch struct {
value string
}
type ResourcePriceArchEnum struct {
X86 ResourcePriceArch
ARM ResourcePriceArch
}
func GetResourcePriceArchEnum() ResourcePriceArchEnum {
return ResourcePriceArchEnum{
X86: ResourcePriceArch{
value: "x86",
},
ARM: ResourcePriceArch{
value: "arm",
},
}
}
func (c ResourcePriceArch) Value() string {
return c.value
}
func (c ResourcePriceArch) MarshalJSON() ([]byte, error) {
return utils.Marshal(c.value)
}
func (c *ResourcePriceArch) UnmarshalJSON(b []byte) error {
myConverter := converter.StringConverterFactory("string")
if myConverter == nil {
return errors.New("unsupported StringConverter type: string")
}
interf, err := myConverter.CovertStringToInterface(strings.Trim(string(b[:]), "\""))
if err != nil {
return err
}
if val, ok := interf.(string); ok {
c.value = val
return nil
} else {
return errors.New("convert enum data to string error")
}
}