/
models.go
485 lines (459 loc) · 11.7 KB
/
models.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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
package additionalproperties
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"encoding/json"
"github.com/Azure/go-autorest/autorest"
)
// The package's fully qualified name.
const fqdn = "tests/generated/additionalproperties"
// CatAPTrue ...
type CatAPTrue struct {
autorest.Response `json:"-"`
Friendly *bool `json:"friendly,omitempty"`
// AdditionalProperties - Unmatched properties from the message are deserialized this collection
AdditionalProperties map[string]interface{} `json:""`
ID *int32 `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
// Status - READ-ONLY
Status *bool `json:"status,omitempty"`
}
// MarshalJSON is the custom marshaler for CatAPTrue.
func (cat CatAPTrue) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if cat.Friendly != nil {
objectMap["friendly"] = cat.Friendly
}
if cat.ID != nil {
objectMap["id"] = cat.ID
}
if cat.Name != nil {
objectMap["name"] = cat.Name
}
for k, v := range cat.AdditionalProperties {
objectMap[k] = v
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for CatAPTrue struct.
func (cat *CatAPTrue) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "friendly":
if v != nil {
var friendly bool
err = json.Unmarshal(*v, &friendly)
if err != nil {
return err
}
cat.Friendly = &friendly
}
default:
if v != nil {
var additionalProperties interface{}
err = json.Unmarshal(*v, &additionalProperties)
if err != nil {
return err
}
if cat.AdditionalProperties == nil {
cat.AdditionalProperties = make(map[string]interface{})
}
cat.AdditionalProperties[k] = additionalProperties
}
case "id":
if v != nil {
var ID int32
err = json.Unmarshal(*v, &ID)
if err != nil {
return err
}
cat.ID = &ID
}
case "name":
if v != nil {
var name string
err = json.Unmarshal(*v, &name)
if err != nil {
return err
}
cat.Name = &name
}
case "status":
if v != nil {
var status bool
err = json.Unmarshal(*v, &status)
if err != nil {
return err
}
cat.Status = &status
}
}
}
return nil
}
// Error ...
type Error struct {
Status *int32 `json:"status,omitempty"`
Message *string `json:"message,omitempty"`
}
// PetAPInProperties ...
type PetAPInProperties struct {
autorest.Response `json:"-"`
ID *int32 `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
// Status - READ-ONLY
Status *bool `json:"status,omitempty"`
AdditionalProperties map[string]*float64 `json:"additionalProperties"`
}
// MarshalJSON is the custom marshaler for PetAPInProperties.
func (paip PetAPInProperties) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if paip.ID != nil {
objectMap["id"] = paip.ID
}
if paip.Name != nil {
objectMap["name"] = paip.Name
}
if paip.AdditionalProperties != nil {
objectMap["additionalProperties"] = paip.AdditionalProperties
}
return json.Marshal(objectMap)
}
// PetAPInPropertiesWithAPString ...
type PetAPInPropertiesWithAPString struct {
autorest.Response `json:"-"`
// AdditionalProperties - Unmatched properties from the message are deserialized this collection
AdditionalProperties map[string]*string `json:""`
ID *int32 `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
// Status - READ-ONLY
Status *bool `json:"status,omitempty"`
OdataLocation *string `json:"@odata.location,omitempty"`
AdditionalProperties1 map[string]*float64 `json:"additionalProperties"`
}
// MarshalJSON is the custom marshaler for PetAPInPropertiesWithAPString.
func (paipwas PetAPInPropertiesWithAPString) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if paipwas.ID != nil {
objectMap["id"] = paipwas.ID
}
if paipwas.Name != nil {
objectMap["name"] = paipwas.Name
}
if paipwas.OdataLocation != nil {
objectMap["@odata.location"] = paipwas.OdataLocation
}
if paipwas.AdditionalProperties1 != nil {
objectMap["additionalProperties"] = paipwas.AdditionalProperties1
}
for k, v := range paipwas.AdditionalProperties {
objectMap[k] = v
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for PetAPInPropertiesWithAPString struct.
func (paipwas *PetAPInPropertiesWithAPString) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
default:
if v != nil {
var additionalProperties string
err = json.Unmarshal(*v, &additionalProperties)
if err != nil {
return err
}
if paipwas.AdditionalProperties == nil {
paipwas.AdditionalProperties = make(map[string]*string)
}
paipwas.AdditionalProperties[k] = &additionalProperties
}
case "id":
if v != nil {
var ID int32
err = json.Unmarshal(*v, &ID)
if err != nil {
return err
}
paipwas.ID = &ID
}
case "name":
if v != nil {
var name string
err = json.Unmarshal(*v, &name)
if err != nil {
return err
}
paipwas.Name = &name
}
case "status":
if v != nil {
var status bool
err = json.Unmarshal(*v, &status)
if err != nil {
return err
}
paipwas.Status = &status
}
case "@odata.location":
if v != nil {
var odataLocation string
err = json.Unmarshal(*v, &odataLocation)
if err != nil {
return err
}
paipwas.OdataLocation = &odataLocation
}
case "additionalProperties":
if v != nil {
var additionalProperties1 map[string]*float64
err = json.Unmarshal(*v, &additionalProperties1)
if err != nil {
return err
}
paipwas.AdditionalProperties1 = additionalProperties1
}
}
}
return nil
}
// PetAPObject ...
type PetAPObject struct {
autorest.Response `json:"-"`
// AdditionalProperties - Unmatched properties from the message are deserialized this collection
AdditionalProperties map[string]interface{} `json:""`
ID *int32 `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
// Status - READ-ONLY
Status *bool `json:"status,omitempty"`
}
// MarshalJSON is the custom marshaler for PetAPObject.
func (pao PetAPObject) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if pao.ID != nil {
objectMap["id"] = pao.ID
}
if pao.Name != nil {
objectMap["name"] = pao.Name
}
for k, v := range pao.AdditionalProperties {
objectMap[k] = v
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for PetAPObject struct.
func (pao *PetAPObject) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
default:
if v != nil {
var additionalProperties interface{}
err = json.Unmarshal(*v, &additionalProperties)
if err != nil {
return err
}
if pao.AdditionalProperties == nil {
pao.AdditionalProperties = make(map[string]interface{})
}
pao.AdditionalProperties[k] = additionalProperties
}
case "id":
if v != nil {
var ID int32
err = json.Unmarshal(*v, &ID)
if err != nil {
return err
}
pao.ID = &ID
}
case "name":
if v != nil {
var name string
err = json.Unmarshal(*v, &name)
if err != nil {
return err
}
pao.Name = &name
}
case "status":
if v != nil {
var status bool
err = json.Unmarshal(*v, &status)
if err != nil {
return err
}
pao.Status = &status
}
}
}
return nil
}
// PetAPString ...
type PetAPString struct {
autorest.Response `json:"-"`
// AdditionalProperties - Unmatched properties from the message are deserialized this collection
AdditionalProperties map[string]*string `json:""`
ID *int32 `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
// Status - READ-ONLY
Status *bool `json:"status,omitempty"`
}
// MarshalJSON is the custom marshaler for PetAPString.
func (pas PetAPString) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if pas.ID != nil {
objectMap["id"] = pas.ID
}
if pas.Name != nil {
objectMap["name"] = pas.Name
}
for k, v := range pas.AdditionalProperties {
objectMap[k] = v
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for PetAPString struct.
func (pas *PetAPString) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
default:
if v != nil {
var additionalProperties string
err = json.Unmarshal(*v, &additionalProperties)
if err != nil {
return err
}
if pas.AdditionalProperties == nil {
pas.AdditionalProperties = make(map[string]*string)
}
pas.AdditionalProperties[k] = &additionalProperties
}
case "id":
if v != nil {
var ID int32
err = json.Unmarshal(*v, &ID)
if err != nil {
return err
}
pas.ID = &ID
}
case "name":
if v != nil {
var name string
err = json.Unmarshal(*v, &name)
if err != nil {
return err
}
pas.Name = &name
}
case "status":
if v != nil {
var status bool
err = json.Unmarshal(*v, &status)
if err != nil {
return err
}
pas.Status = &status
}
}
}
return nil
}
// PetAPTrue ...
type PetAPTrue struct {
autorest.Response `json:"-"`
// AdditionalProperties - Unmatched properties from the message are deserialized this collection
AdditionalProperties map[string]interface{} `json:""`
ID *int32 `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
// Status - READ-ONLY
Status *bool `json:"status,omitempty"`
}
// MarshalJSON is the custom marshaler for PetAPTrue.
func (pat PetAPTrue) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if pat.ID != nil {
objectMap["id"] = pat.ID
}
if pat.Name != nil {
objectMap["name"] = pat.Name
}
for k, v := range pat.AdditionalProperties {
objectMap[k] = v
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for PetAPTrue struct.
func (pat *PetAPTrue) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
default:
if v != nil {
var additionalProperties interface{}
err = json.Unmarshal(*v, &additionalProperties)
if err != nil {
return err
}
if pat.AdditionalProperties == nil {
pat.AdditionalProperties = make(map[string]interface{})
}
pat.AdditionalProperties[k] = additionalProperties
}
case "id":
if v != nil {
var ID int32
err = json.Unmarshal(*v, &ID)
if err != nil {
return err
}
pat.ID = &ID
}
case "name":
if v != nil {
var name string
err = json.Unmarshal(*v, &name)
if err != nil {
return err
}
pat.Name = &name
}
case "status":
if v != nil {
var status bool
err = json.Unmarshal(*v, &status)
if err != nil {
return err
}
pat.Status = &status
}
}
}
return nil
}