-
Notifications
You must be signed in to change notification settings - Fork 26
/
model_ui_node_attributes.go
287 lines (241 loc) · 9.12 KB
/
model_ui_node_attributes.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
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
282
283
284
285
/*
Ory Identities API
This is the API specification for Ory Identities with features such as registration, login, recovery, account verification, profile settings, password reset, identity management, session management, email and sms delivery, and more.
API version: v1.2.1
Contact: [email protected]
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package client
import (
"encoding/json"
"fmt"
)
// UiNodeAttributes - struct for UiNodeAttributes
type UiNodeAttributes struct {
UiNodeAnchorAttributes *UiNodeAnchorAttributes
UiNodeImageAttributes *UiNodeImageAttributes
UiNodeInputAttributes *UiNodeInputAttributes
UiNodeScriptAttributes *UiNodeScriptAttributes
UiNodeTextAttributes *UiNodeTextAttributes
}
// UiNodeAnchorAttributesAsUiNodeAttributes is a convenience function that returns UiNodeAnchorAttributes wrapped in UiNodeAttributes
func UiNodeAnchorAttributesAsUiNodeAttributes(v *UiNodeAnchorAttributes) UiNodeAttributes {
return UiNodeAttributes{
UiNodeAnchorAttributes: v,
}
}
// UiNodeImageAttributesAsUiNodeAttributes is a convenience function that returns UiNodeImageAttributes wrapped in UiNodeAttributes
func UiNodeImageAttributesAsUiNodeAttributes(v *UiNodeImageAttributes) UiNodeAttributes {
return UiNodeAttributes{
UiNodeImageAttributes: v,
}
}
// UiNodeInputAttributesAsUiNodeAttributes is a convenience function that returns UiNodeInputAttributes wrapped in UiNodeAttributes
func UiNodeInputAttributesAsUiNodeAttributes(v *UiNodeInputAttributes) UiNodeAttributes {
return UiNodeAttributes{
UiNodeInputAttributes: v,
}
}
// UiNodeScriptAttributesAsUiNodeAttributes is a convenience function that returns UiNodeScriptAttributes wrapped in UiNodeAttributes
func UiNodeScriptAttributesAsUiNodeAttributes(v *UiNodeScriptAttributes) UiNodeAttributes {
return UiNodeAttributes{
UiNodeScriptAttributes: v,
}
}
// UiNodeTextAttributesAsUiNodeAttributes is a convenience function that returns UiNodeTextAttributes wrapped in UiNodeAttributes
func UiNodeTextAttributesAsUiNodeAttributes(v *UiNodeTextAttributes) UiNodeAttributes {
return UiNodeAttributes{
UiNodeTextAttributes: v,
}
}
// Unmarshal JSON data into one of the pointers in the struct
func (dst *UiNodeAttributes) 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 'a'
if jsonDict["node_type"] == "a" {
// try to unmarshal JSON data into UiNodeAnchorAttributes
err = json.Unmarshal(data, &dst.UiNodeAnchorAttributes)
if err == nil {
return nil // data stored in dst.UiNodeAnchorAttributes, return on the first match
} else {
dst.UiNodeAnchorAttributes = nil
return fmt.Errorf("failed to unmarshal UiNodeAttributes as UiNodeAnchorAttributes: %s", err.Error())
}
}
// check if the discriminator value is 'img'
if jsonDict["node_type"] == "img" {
// try to unmarshal JSON data into UiNodeImageAttributes
err = json.Unmarshal(data, &dst.UiNodeImageAttributes)
if err == nil {
return nil // data stored in dst.UiNodeImageAttributes, return on the first match
} else {
dst.UiNodeImageAttributes = nil
return fmt.Errorf("failed to unmarshal UiNodeAttributes as UiNodeImageAttributes: %s", err.Error())
}
}
// check if the discriminator value is 'input'
if jsonDict["node_type"] == "input" {
// try to unmarshal JSON data into UiNodeInputAttributes
err = json.Unmarshal(data, &dst.UiNodeInputAttributes)
if err == nil {
return nil // data stored in dst.UiNodeInputAttributes, return on the first match
} else {
dst.UiNodeInputAttributes = nil
return fmt.Errorf("failed to unmarshal UiNodeAttributes as UiNodeInputAttributes: %s", err.Error())
}
}
// check if the discriminator value is 'script'
if jsonDict["node_type"] == "script" {
// try to unmarshal JSON data into UiNodeScriptAttributes
err = json.Unmarshal(data, &dst.UiNodeScriptAttributes)
if err == nil {
return nil // data stored in dst.UiNodeScriptAttributes, return on the first match
} else {
dst.UiNodeScriptAttributes = nil
return fmt.Errorf("failed to unmarshal UiNodeAttributes as UiNodeScriptAttributes: %s", err.Error())
}
}
// check if the discriminator value is 'text'
if jsonDict["node_type"] == "text" {
// try to unmarshal JSON data into UiNodeTextAttributes
err = json.Unmarshal(data, &dst.UiNodeTextAttributes)
if err == nil {
return nil // data stored in dst.UiNodeTextAttributes, return on the first match
} else {
dst.UiNodeTextAttributes = nil
return fmt.Errorf("failed to unmarshal UiNodeAttributes as UiNodeTextAttributes: %s", err.Error())
}
}
// check if the discriminator value is 'uiNodeAnchorAttributes'
if jsonDict["node_type"] == "uiNodeAnchorAttributes" {
// try to unmarshal JSON data into UiNodeAnchorAttributes
err = json.Unmarshal(data, &dst.UiNodeAnchorAttributes)
if err == nil {
return nil // data stored in dst.UiNodeAnchorAttributes, return on the first match
} else {
dst.UiNodeAnchorAttributes = nil
return fmt.Errorf("failed to unmarshal UiNodeAttributes as UiNodeAnchorAttributes: %s", err.Error())
}
}
// check if the discriminator value is 'uiNodeImageAttributes'
if jsonDict["node_type"] == "uiNodeImageAttributes" {
// try to unmarshal JSON data into UiNodeImageAttributes
err = json.Unmarshal(data, &dst.UiNodeImageAttributes)
if err == nil {
return nil // data stored in dst.UiNodeImageAttributes, return on the first match
} else {
dst.UiNodeImageAttributes = nil
return fmt.Errorf("failed to unmarshal UiNodeAttributes as UiNodeImageAttributes: %s", err.Error())
}
}
// check if the discriminator value is 'uiNodeInputAttributes'
if jsonDict["node_type"] == "uiNodeInputAttributes" {
// try to unmarshal JSON data into UiNodeInputAttributes
err = json.Unmarshal(data, &dst.UiNodeInputAttributes)
if err == nil {
return nil // data stored in dst.UiNodeInputAttributes, return on the first match
} else {
dst.UiNodeInputAttributes = nil
return fmt.Errorf("failed to unmarshal UiNodeAttributes as UiNodeInputAttributes: %s", err.Error())
}
}
// check if the discriminator value is 'uiNodeScriptAttributes'
if jsonDict["node_type"] == "uiNodeScriptAttributes" {
// try to unmarshal JSON data into UiNodeScriptAttributes
err = json.Unmarshal(data, &dst.UiNodeScriptAttributes)
if err == nil {
return nil // data stored in dst.UiNodeScriptAttributes, return on the first match
} else {
dst.UiNodeScriptAttributes = nil
return fmt.Errorf("failed to unmarshal UiNodeAttributes as UiNodeScriptAttributes: %s", err.Error())
}
}
// check if the discriminator value is 'uiNodeTextAttributes'
if jsonDict["node_type"] == "uiNodeTextAttributes" {
// try to unmarshal JSON data into UiNodeTextAttributes
err = json.Unmarshal(data, &dst.UiNodeTextAttributes)
if err == nil {
return nil // data stored in dst.UiNodeTextAttributes, return on the first match
} else {
dst.UiNodeTextAttributes = nil
return fmt.Errorf("failed to unmarshal UiNodeAttributes as UiNodeTextAttributes: %s", err.Error())
}
}
return nil
}
// Marshal data from the first non-nil pointers in the struct to JSON
func (src UiNodeAttributes) MarshalJSON() ([]byte, error) {
if src.UiNodeAnchorAttributes != nil {
return json.Marshal(&src.UiNodeAnchorAttributes)
}
if src.UiNodeImageAttributes != nil {
return json.Marshal(&src.UiNodeImageAttributes)
}
if src.UiNodeInputAttributes != nil {
return json.Marshal(&src.UiNodeInputAttributes)
}
if src.UiNodeScriptAttributes != nil {
return json.Marshal(&src.UiNodeScriptAttributes)
}
if src.UiNodeTextAttributes != nil {
return json.Marshal(&src.UiNodeTextAttributes)
}
return nil, nil // no data in oneOf schemas
}
// Get the actual instance
func (obj *UiNodeAttributes) GetActualInstance() (interface{}) {
if obj == nil {
return nil
}
if obj.UiNodeAnchorAttributes != nil {
return obj.UiNodeAnchorAttributes
}
if obj.UiNodeImageAttributes != nil {
return obj.UiNodeImageAttributes
}
if obj.UiNodeInputAttributes != nil {
return obj.UiNodeInputAttributes
}
if obj.UiNodeScriptAttributes != nil {
return obj.UiNodeScriptAttributes
}
if obj.UiNodeTextAttributes != nil {
return obj.UiNodeTextAttributes
}
// all schemas are nil
return nil
}
type NullableUiNodeAttributes struct {
value *UiNodeAttributes
isSet bool
}
func (v NullableUiNodeAttributes) Get() *UiNodeAttributes {
return v.value
}
func (v *NullableUiNodeAttributes) Set(val *UiNodeAttributes) {
v.value = val
v.isSet = true
}
func (v NullableUiNodeAttributes) IsSet() bool {
return v.isSet
}
func (v *NullableUiNodeAttributes) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableUiNodeAttributes(val *UiNodeAttributes) *NullableUiNodeAttributes {
return &NullableUiNodeAttributes{value: val, isSet: true}
}
func (v NullableUiNodeAttributes) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableUiNodeAttributes) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}