forked from kubeflow/hub
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel_metadata_value.go
More file actions
281 lines (232 loc) · 7.74 KB
/
model_metadata_value.go
File metadata and controls
281 lines (232 loc) · 7.74 KB
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
/*
Model Registry REST API
REST API for Model Registry to create and manage ML model metadata
API version: v1alpha3
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package openapi
import (
"encoding/json"
"fmt"
)
// MetadataValue - A value in properties.
type MetadataValue struct {
MetadataBoolValue *MetadataBoolValue
MetadataDoubleValue *MetadataDoubleValue
MetadataIntValue *MetadataIntValue
MetadataProtoValue *MetadataProtoValue
MetadataStringValue *MetadataStringValue
MetadataStructValue *MetadataStructValue
}
// MetadataBoolValueAsMetadataValue is a convenience function that returns MetadataBoolValue wrapped in MetadataValue
func MetadataBoolValueAsMetadataValue(v *MetadataBoolValue) MetadataValue {
return MetadataValue{
MetadataBoolValue: v,
}
}
// MetadataDoubleValueAsMetadataValue is a convenience function that returns MetadataDoubleValue wrapped in MetadataValue
func MetadataDoubleValueAsMetadataValue(v *MetadataDoubleValue) MetadataValue {
return MetadataValue{
MetadataDoubleValue: v,
}
}
// MetadataIntValueAsMetadataValue is a convenience function that returns MetadataIntValue wrapped in MetadataValue
func MetadataIntValueAsMetadataValue(v *MetadataIntValue) MetadataValue {
return MetadataValue{
MetadataIntValue: v,
}
}
// MetadataProtoValueAsMetadataValue is a convenience function that returns MetadataProtoValue wrapped in MetadataValue
func MetadataProtoValueAsMetadataValue(v *MetadataProtoValue) MetadataValue {
return MetadataValue{
MetadataProtoValue: v,
}
}
// MetadataStringValueAsMetadataValue is a convenience function that returns MetadataStringValue wrapped in MetadataValue
func MetadataStringValueAsMetadataValue(v *MetadataStringValue) MetadataValue {
return MetadataValue{
MetadataStringValue: v,
}
}
// MetadataStructValueAsMetadataValue is a convenience function that returns MetadataStructValue wrapped in MetadataValue
func MetadataStructValueAsMetadataValue(v *MetadataStructValue) MetadataValue {
return MetadataValue{
MetadataStructValue: v,
}
}
// Unmarshal JSON data into one of the pointers in the struct
func (dst *MetadataValue) UnmarshalJSON(data []byte) error {
var err error
// use discriminator value to speed up the lookup
var jsonDict map[string]interface{}
err = newStrictDecoder(data).Decode(&jsonDict)
if err != nil {
return fmt.Errorf("failed to unmarshal JSON into map for the discriminator lookup")
}
// check if the discriminator value is 'MetadataBoolValue'
if jsonDict["metadataType"] == "MetadataBoolValue" {
// try to unmarshal JSON data into MetadataBoolValue
err = json.Unmarshal(data, &dst.MetadataBoolValue)
if err == nil {
return nil // data stored in dst.MetadataBoolValue, return on the first match
} else {
dst.MetadataBoolValue = nil
return fmt.Errorf("failed to unmarshal MetadataValue as MetadataBoolValue: %s", err.Error())
}
}
// check if the discriminator value is 'MetadataDoubleValue'
if jsonDict["metadataType"] == "MetadataDoubleValue" {
// try to unmarshal JSON data into MetadataDoubleValue
err = json.Unmarshal(data, &dst.MetadataDoubleValue)
if err == nil {
return nil // data stored in dst.MetadataDoubleValue, return on the first match
} else {
dst.MetadataDoubleValue = nil
return fmt.Errorf("failed to unmarshal MetadataValue as MetadataDoubleValue: %s", err.Error())
}
}
// check if the discriminator value is 'MetadataIntValue'
if jsonDict["metadataType"] == "MetadataIntValue" {
// try to unmarshal JSON data into MetadataIntValue
err = json.Unmarshal(data, &dst.MetadataIntValue)
if err == nil {
return nil // data stored in dst.MetadataIntValue, return on the first match
} else {
dst.MetadataIntValue = nil
return fmt.Errorf("failed to unmarshal MetadataValue as MetadataIntValue: %s", err.Error())
}
}
// check if the discriminator value is 'MetadataProtoValue'
if jsonDict["metadataType"] == "MetadataProtoValue" {
// try to unmarshal JSON data into MetadataProtoValue
err = json.Unmarshal(data, &dst.MetadataProtoValue)
if err == nil {
return nil // data stored in dst.MetadataProtoValue, return on the first match
} else {
dst.MetadataProtoValue = nil
return fmt.Errorf("failed to unmarshal MetadataValue as MetadataProtoValue: %s", err.Error())
}
}
// check if the discriminator value is 'MetadataStringValue'
if jsonDict["metadataType"] == "MetadataStringValue" {
// try to unmarshal JSON data into MetadataStringValue
err = json.Unmarshal(data, &dst.MetadataStringValue)
if err == nil {
return nil // data stored in dst.MetadataStringValue, return on the first match
} else {
dst.MetadataStringValue = nil
return fmt.Errorf("failed to unmarshal MetadataValue as MetadataStringValue: %s", err.Error())
}
}
// check if the discriminator value is 'MetadataStructValue'
if jsonDict["metadataType"] == "MetadataStructValue" {
// try to unmarshal JSON data into MetadataStructValue
err = json.Unmarshal(data, &dst.MetadataStructValue)
if err == nil {
return nil // data stored in dst.MetadataStructValue, return on the first match
} else {
dst.MetadataStructValue = nil
return fmt.Errorf("failed to unmarshal MetadataValue as MetadataStructValue: %s", err.Error())
}
}
return nil
}
// Marshal data from the first non-nil pointers in the struct to JSON
func (src MetadataValue) MarshalJSON() ([]byte, error) {
if src.MetadataBoolValue != nil {
return json.Marshal(&src.MetadataBoolValue)
}
if src.MetadataDoubleValue != nil {
return json.Marshal(&src.MetadataDoubleValue)
}
if src.MetadataIntValue != nil {
return json.Marshal(&src.MetadataIntValue)
}
if src.MetadataProtoValue != nil {
return json.Marshal(&src.MetadataProtoValue)
}
if src.MetadataStringValue != nil {
return json.Marshal(&src.MetadataStringValue)
}
if src.MetadataStructValue != nil {
return json.Marshal(&src.MetadataStructValue)
}
return nil, nil // no data in oneOf schemas
}
// Get the actual instance
func (obj *MetadataValue) GetActualInstance() interface{} {
if obj == nil {
return nil
}
if obj.MetadataBoolValue != nil {
return obj.MetadataBoolValue
}
if obj.MetadataDoubleValue != nil {
return obj.MetadataDoubleValue
}
if obj.MetadataIntValue != nil {
return obj.MetadataIntValue
}
if obj.MetadataProtoValue != nil {
return obj.MetadataProtoValue
}
if obj.MetadataStringValue != nil {
return obj.MetadataStringValue
}
if obj.MetadataStructValue != nil {
return obj.MetadataStructValue
}
// all schemas are nil
return nil
}
// Get the actual instance value
func (obj MetadataValue) GetActualInstanceValue() interface{} {
if obj.MetadataBoolValue != nil {
return *obj.MetadataBoolValue
}
if obj.MetadataDoubleValue != nil {
return *obj.MetadataDoubleValue
}
if obj.MetadataIntValue != nil {
return *obj.MetadataIntValue
}
if obj.MetadataProtoValue != nil {
return *obj.MetadataProtoValue
}
if obj.MetadataStringValue != nil {
return *obj.MetadataStringValue
}
if obj.MetadataStructValue != nil {
return *obj.MetadataStructValue
}
// all schemas are nil
return nil
}
type NullableMetadataValue struct {
value *MetadataValue
isSet bool
}
func (v NullableMetadataValue) Get() *MetadataValue {
return v.value
}
func (v *NullableMetadataValue) Set(val *MetadataValue) {
v.value = val
v.isSet = true
}
func (v NullableMetadataValue) IsSet() bool {
return v.isSet
}
func (v *NullableMetadataValue) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableMetadataValue(val *MetadataValue) *NullableMetadataValue {
return &NullableMetadataValue{value: val, isSet: true}
}
func (v NullableMetadataValue) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableMetadataValue) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}