-
Notifications
You must be signed in to change notification settings - Fork 18
/
cloudnetworkconfigdata.go
211 lines (167 loc) · 5.96 KB
/
cloudnetworkconfigdata.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
// Code generated by elegen. DO NOT EDIT.
// Source: go.aporeto.io/elemental (templates/model.gotpl)
package gaia
import (
"fmt"
"github.com/globalsign/mgo/bson"
"github.com/mitchellh/copystructure"
"go.aporeto.io/elemental"
)
// CloudNetworkConfigData represents the model of a cloudnetworkconfigdata
type CloudNetworkConfigData struct {
// IP configurations of the NICs in the Scale Set.
IpConfigurations []*CloudIPConfiguration `json:"ipConfigurations" msgpack:"ipConfigurations" bson:"ipconfigurations" mapstructure:"ipConfigurations,omitempty"`
// Network configuration name of the NIC associated in the Scale Set.
NetworkConfigName string `json:"networkConfigName" msgpack:"networkConfigName" bson:"networkconfigname" mapstructure:"networkConfigName,omitempty"`
ModelVersion int `json:"-" msgpack:"-" bson:"_modelversion"`
}
// NewCloudNetworkConfigData returns a new *CloudNetworkConfigData
func NewCloudNetworkConfigData() *CloudNetworkConfigData {
return &CloudNetworkConfigData{
ModelVersion: 1,
IpConfigurations: []*CloudIPConfiguration{},
}
}
// GetBSON implements the bson marshaling interface.
// This is used to transparently convert ID to MongoDBID as ObectID.
func (o *CloudNetworkConfigData) GetBSON() (any, error) {
if o == nil {
return nil, nil
}
s := &mongoAttributesCloudNetworkConfigData{}
s.IpConfigurations = o.IpConfigurations
s.NetworkConfigName = o.NetworkConfigName
return s, nil
}
// SetBSON implements the bson marshaling interface.
// This is used to transparently convert ID to MongoDBID as ObectID.
func (o *CloudNetworkConfigData) SetBSON(raw bson.Raw) error {
if o == nil {
return nil
}
s := &mongoAttributesCloudNetworkConfigData{}
if err := raw.Unmarshal(s); err != nil {
return err
}
o.IpConfigurations = s.IpConfigurations
o.NetworkConfigName = s.NetworkConfigName
return nil
}
// BleveType implements the bleve.Classifier Interface.
func (o *CloudNetworkConfigData) BleveType() string {
return "cloudnetworkconfigdata"
}
// DeepCopy returns a deep copy if the CloudNetworkConfigData.
func (o *CloudNetworkConfigData) DeepCopy() *CloudNetworkConfigData {
if o == nil {
return nil
}
out := &CloudNetworkConfigData{}
o.DeepCopyInto(out)
return out
}
// DeepCopyInto copies the receiver into the given *CloudNetworkConfigData.
func (o *CloudNetworkConfigData) DeepCopyInto(out *CloudNetworkConfigData) {
target, err := copystructure.Copy(o)
if err != nil {
panic(fmt.Sprintf("Unable to deepcopy CloudNetworkConfigData: %s", err))
}
*out = *target.(*CloudNetworkConfigData)
}
// Validate valides the current information stored into the structure.
func (o *CloudNetworkConfigData) Validate() error {
errors := elemental.Errors{}
requiredErrors := elemental.Errors{}
for _, sub := range o.IpConfigurations {
if sub == nil {
continue
}
elemental.ResetDefaultForZeroValues(sub)
if err := sub.Validate(); err != nil {
errors = errors.Append(err)
}
}
if len(requiredErrors) > 0 {
return requiredErrors
}
if len(errors) > 0 {
return errors
}
return nil
}
// SpecificationForAttribute returns the AttributeSpecification for the given attribute name key.
func (*CloudNetworkConfigData) SpecificationForAttribute(name string) elemental.AttributeSpecification {
if v, ok := CloudNetworkConfigDataAttributesMap[name]; ok {
return v
}
// We could not find it, so let's check on the lower case indexed spec map
return CloudNetworkConfigDataLowerCaseAttributesMap[name]
}
// AttributeSpecifications returns the full attribute specifications map.
func (*CloudNetworkConfigData) AttributeSpecifications() map[string]elemental.AttributeSpecification {
return CloudNetworkConfigDataAttributesMap
}
// ValueForAttribute returns the value for the given attribute.
// This is a very advanced function that you should not need but in some
// very specific use cases.
func (o *CloudNetworkConfigData) ValueForAttribute(name string) any {
switch name {
case "ipConfigurations":
return o.IpConfigurations
case "networkConfigName":
return o.NetworkConfigName
}
return nil
}
// CloudNetworkConfigDataAttributesMap represents the map of attribute for CloudNetworkConfigData.
var CloudNetworkConfigDataAttributesMap = map[string]elemental.AttributeSpecification{
"IpConfigurations": {
AllowedChoices: []string{},
BSONFieldName: "ipconfigurations",
ConvertedName: "IpConfigurations",
Description: `IP configurations of the NICs in the Scale Set.`,
Exposed: true,
Name: "ipConfigurations",
Stored: true,
SubType: "cloudipconfiguration",
Type: "refList",
},
"NetworkConfigName": {
AllowedChoices: []string{},
BSONFieldName: "networkconfigname",
ConvertedName: "NetworkConfigName",
Description: `Network configuration name of the NIC associated in the Scale Set.`,
Exposed: true,
Name: "networkConfigName",
Stored: true,
Type: "string",
},
}
// CloudNetworkConfigDataLowerCaseAttributesMap represents the map of attribute for CloudNetworkConfigData.
var CloudNetworkConfigDataLowerCaseAttributesMap = map[string]elemental.AttributeSpecification{
"ipconfigurations": {
AllowedChoices: []string{},
BSONFieldName: "ipconfigurations",
ConvertedName: "IpConfigurations",
Description: `IP configurations of the NICs in the Scale Set.`,
Exposed: true,
Name: "ipConfigurations",
Stored: true,
SubType: "cloudipconfiguration",
Type: "refList",
},
"networkconfigname": {
AllowedChoices: []string{},
BSONFieldName: "networkconfigname",
ConvertedName: "NetworkConfigName",
Description: `Network configuration name of the NIC associated in the Scale Set.`,
Exposed: true,
Name: "networkConfigName",
Stored: true,
Type: "string",
},
}
type mongoAttributesCloudNetworkConfigData struct {
IpConfigurations []*CloudIPConfiguration `bson:"ipconfigurations"`
NetworkConfigName string `bson:"networkconfigname"`
}