-
Notifications
You must be signed in to change notification settings - Fork 1
/
model_entity_1.go
528 lines (458 loc) · 12.6 KB
/
model_entity_1.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
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
/*
FastAPI
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
API version: 0.1.0
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package goyeti
import (
"encoding/json"
"fmt"
"gopkg.in/validator.v2"
)
// Entity1 - struct for Entity1
type Entity1 struct {
AttackPatternInput *AttackPatternInput
CampaignInput *CampaignInput
CompanyInput *CompanyInput
CourseOfActionInput *CourseOfActionInput
IdentityInput *IdentityInput
IntrusionSetInput *IntrusionSetInput
InvestigationInput *InvestigationInput
MalwareInput *MalwareInput
NoteInput *NoteInput
PhoneInput *PhoneInput
ThreatActorInput *ThreatActorInput
ToolInput *ToolInput
VulnerabilityInput *VulnerabilityInput
}
// AttackPatternInputAsEntity1 is a convenience function that returns AttackPatternInput wrapped in Entity1
func AttackPatternInputAsEntity1(v *AttackPatternInput) Entity1 {
return Entity1{
AttackPatternInput: v,
}
}
// CampaignInputAsEntity1 is a convenience function that returns CampaignInput wrapped in Entity1
func CampaignInputAsEntity1(v *CampaignInput) Entity1 {
return Entity1{
CampaignInput: v,
}
}
// CompanyInputAsEntity1 is a convenience function that returns CompanyInput wrapped in Entity1
func CompanyInputAsEntity1(v *CompanyInput) Entity1 {
return Entity1{
CompanyInput: v,
}
}
// CourseOfActionInputAsEntity1 is a convenience function that returns CourseOfActionInput wrapped in Entity1
func CourseOfActionInputAsEntity1(v *CourseOfActionInput) Entity1 {
return Entity1{
CourseOfActionInput: v,
}
}
// IdentityInputAsEntity1 is a convenience function that returns IdentityInput wrapped in Entity1
func IdentityInputAsEntity1(v *IdentityInput) Entity1 {
return Entity1{
IdentityInput: v,
}
}
// IntrusionSetInputAsEntity1 is a convenience function that returns IntrusionSetInput wrapped in Entity1
func IntrusionSetInputAsEntity1(v *IntrusionSetInput) Entity1 {
return Entity1{
IntrusionSetInput: v,
}
}
// InvestigationInputAsEntity1 is a convenience function that returns InvestigationInput wrapped in Entity1
func InvestigationInputAsEntity1(v *InvestigationInput) Entity1 {
return Entity1{
InvestigationInput: v,
}
}
// MalwareInputAsEntity1 is a convenience function that returns MalwareInput wrapped in Entity1
func MalwareInputAsEntity1(v *MalwareInput) Entity1 {
return Entity1{
MalwareInput: v,
}
}
// NoteInputAsEntity1 is a convenience function that returns NoteInput wrapped in Entity1
func NoteInputAsEntity1(v *NoteInput) Entity1 {
return Entity1{
NoteInput: v,
}
}
// PhoneInputAsEntity1 is a convenience function that returns PhoneInput wrapped in Entity1
func PhoneInputAsEntity1(v *PhoneInput) Entity1 {
return Entity1{
PhoneInput: v,
}
}
// ThreatActorInputAsEntity1 is a convenience function that returns ThreatActorInput wrapped in Entity1
func ThreatActorInputAsEntity1(v *ThreatActorInput) Entity1 {
return Entity1{
ThreatActorInput: v,
}
}
// ToolInputAsEntity1 is a convenience function that returns ToolInput wrapped in Entity1
func ToolInputAsEntity1(v *ToolInput) Entity1 {
return Entity1{
ToolInput: v,
}
}
// VulnerabilityInputAsEntity1 is a convenience function that returns VulnerabilityInput wrapped in Entity1
func VulnerabilityInputAsEntity1(v *VulnerabilityInput) Entity1 {
return Entity1{
VulnerabilityInput: v,
}
}
// Unmarshal JSON data into one of the pointers in the struct
func (dst *Entity1) UnmarshalJSON(data []byte) error {
var err error
match := 0
// try to unmarshal data into AttackPatternInput
err = newStrictDecoder(data).Decode(&dst.AttackPatternInput)
if err == nil {
jsonAttackPatternInput, _ := json.Marshal(dst.AttackPatternInput)
if string(jsonAttackPatternInput) == "{}" { // empty struct
dst.AttackPatternInput = nil
} else {
if err = validator.Validate(dst.AttackPatternInput); err != nil {
dst.AttackPatternInput = nil
} else {
match++
}
}
} else {
dst.AttackPatternInput = nil
}
// try to unmarshal data into CampaignInput
err = newStrictDecoder(data).Decode(&dst.CampaignInput)
if err == nil {
jsonCampaignInput, _ := json.Marshal(dst.CampaignInput)
if string(jsonCampaignInput) == "{}" { // empty struct
dst.CampaignInput = nil
} else {
if err = validator.Validate(dst.CampaignInput); err != nil {
dst.CampaignInput = nil
} else {
match++
}
}
} else {
dst.CampaignInput = nil
}
// try to unmarshal data into CompanyInput
err = newStrictDecoder(data).Decode(&dst.CompanyInput)
if err == nil {
jsonCompanyInput, _ := json.Marshal(dst.CompanyInput)
if string(jsonCompanyInput) == "{}" { // empty struct
dst.CompanyInput = nil
} else {
if err = validator.Validate(dst.CompanyInput); err != nil {
dst.CompanyInput = nil
} else {
match++
}
}
} else {
dst.CompanyInput = nil
}
// try to unmarshal data into CourseOfActionInput
err = newStrictDecoder(data).Decode(&dst.CourseOfActionInput)
if err == nil {
jsonCourseOfActionInput, _ := json.Marshal(dst.CourseOfActionInput)
if string(jsonCourseOfActionInput) == "{}" { // empty struct
dst.CourseOfActionInput = nil
} else {
if err = validator.Validate(dst.CourseOfActionInput); err != nil {
dst.CourseOfActionInput = nil
} else {
match++
}
}
} else {
dst.CourseOfActionInput = nil
}
// try to unmarshal data into IdentityInput
err = newStrictDecoder(data).Decode(&dst.IdentityInput)
if err == nil {
jsonIdentityInput, _ := json.Marshal(dst.IdentityInput)
if string(jsonIdentityInput) == "{}" { // empty struct
dst.IdentityInput = nil
} else {
if err = validator.Validate(dst.IdentityInput); err != nil {
dst.IdentityInput = nil
} else {
match++
}
}
} else {
dst.IdentityInput = nil
}
// try to unmarshal data into IntrusionSetInput
err = newStrictDecoder(data).Decode(&dst.IntrusionSetInput)
if err == nil {
jsonIntrusionSetInput, _ := json.Marshal(dst.IntrusionSetInput)
if string(jsonIntrusionSetInput) == "{}" { // empty struct
dst.IntrusionSetInput = nil
} else {
if err = validator.Validate(dst.IntrusionSetInput); err != nil {
dst.IntrusionSetInput = nil
} else {
match++
}
}
} else {
dst.IntrusionSetInput = nil
}
// try to unmarshal data into InvestigationInput
err = newStrictDecoder(data).Decode(&dst.InvestigationInput)
if err == nil {
jsonInvestigationInput, _ := json.Marshal(dst.InvestigationInput)
if string(jsonInvestigationInput) == "{}" { // empty struct
dst.InvestigationInput = nil
} else {
if err = validator.Validate(dst.InvestigationInput); err != nil {
dst.InvestigationInput = nil
} else {
match++
}
}
} else {
dst.InvestigationInput = nil
}
// try to unmarshal data into MalwareInput
err = newStrictDecoder(data).Decode(&dst.MalwareInput)
if err == nil {
jsonMalwareInput, _ := json.Marshal(dst.MalwareInput)
if string(jsonMalwareInput) == "{}" { // empty struct
dst.MalwareInput = nil
} else {
if err = validator.Validate(dst.MalwareInput); err != nil {
dst.MalwareInput = nil
} else {
match++
}
}
} else {
dst.MalwareInput = nil
}
// try to unmarshal data into NoteInput
err = newStrictDecoder(data).Decode(&dst.NoteInput)
if err == nil {
jsonNoteInput, _ := json.Marshal(dst.NoteInput)
if string(jsonNoteInput) == "{}" { // empty struct
dst.NoteInput = nil
} else {
if err = validator.Validate(dst.NoteInput); err != nil {
dst.NoteInput = nil
} else {
match++
}
}
} else {
dst.NoteInput = nil
}
// try to unmarshal data into PhoneInput
err = newStrictDecoder(data).Decode(&dst.PhoneInput)
if err == nil {
jsonPhoneInput, _ := json.Marshal(dst.PhoneInput)
if string(jsonPhoneInput) == "{}" { // empty struct
dst.PhoneInput = nil
} else {
if err = validator.Validate(dst.PhoneInput); err != nil {
dst.PhoneInput = nil
} else {
match++
}
}
} else {
dst.PhoneInput = nil
}
// try to unmarshal data into ThreatActorInput
err = newStrictDecoder(data).Decode(&dst.ThreatActorInput)
if err == nil {
jsonThreatActorInput, _ := json.Marshal(dst.ThreatActorInput)
if string(jsonThreatActorInput) == "{}" { // empty struct
dst.ThreatActorInput = nil
} else {
if err = validator.Validate(dst.ThreatActorInput); err != nil {
dst.ThreatActorInput = nil
} else {
match++
}
}
} else {
dst.ThreatActorInput = nil
}
// try to unmarshal data into ToolInput
err = newStrictDecoder(data).Decode(&dst.ToolInput)
if err == nil {
jsonToolInput, _ := json.Marshal(dst.ToolInput)
if string(jsonToolInput) == "{}" { // empty struct
dst.ToolInput = nil
} else {
if err = validator.Validate(dst.ToolInput); err != nil {
dst.ToolInput = nil
} else {
match++
}
}
} else {
dst.ToolInput = nil
}
// try to unmarshal data into VulnerabilityInput
err = newStrictDecoder(data).Decode(&dst.VulnerabilityInput)
if err == nil {
jsonVulnerabilityInput, _ := json.Marshal(dst.VulnerabilityInput)
if string(jsonVulnerabilityInput) == "{}" { // empty struct
dst.VulnerabilityInput = nil
} else {
if err = validator.Validate(dst.VulnerabilityInput); err != nil {
dst.VulnerabilityInput = nil
} else {
match++
}
}
} else {
dst.VulnerabilityInput = nil
}
if match > 1 { // more than 1 match
// reset to nil
dst.AttackPatternInput = nil
dst.CampaignInput = nil
dst.CompanyInput = nil
dst.CourseOfActionInput = nil
dst.IdentityInput = nil
dst.IntrusionSetInput = nil
dst.InvestigationInput = nil
dst.MalwareInput = nil
dst.NoteInput = nil
dst.PhoneInput = nil
dst.ThreatActorInput = nil
dst.ToolInput = nil
dst.VulnerabilityInput = nil
return fmt.Errorf("data matches more than one schema in oneOf(Entity1)")
} else if match == 1 {
return nil // exactly one match
} else { // no match
return fmt.Errorf("data failed to match schemas in oneOf(Entity1)")
}
}
// Marshal data from the first non-nil pointers in the struct to JSON
func (src Entity1) MarshalJSON() ([]byte, error) {
if src.AttackPatternInput != nil {
return json.Marshal(&src.AttackPatternInput)
}
if src.CampaignInput != nil {
return json.Marshal(&src.CampaignInput)
}
if src.CompanyInput != nil {
return json.Marshal(&src.CompanyInput)
}
if src.CourseOfActionInput != nil {
return json.Marshal(&src.CourseOfActionInput)
}
if src.IdentityInput != nil {
return json.Marshal(&src.IdentityInput)
}
if src.IntrusionSetInput != nil {
return json.Marshal(&src.IntrusionSetInput)
}
if src.InvestigationInput != nil {
return json.Marshal(&src.InvestigationInput)
}
if src.MalwareInput != nil {
return json.Marshal(&src.MalwareInput)
}
if src.NoteInput != nil {
return json.Marshal(&src.NoteInput)
}
if src.PhoneInput != nil {
return json.Marshal(&src.PhoneInput)
}
if src.ThreatActorInput != nil {
return json.Marshal(&src.ThreatActorInput)
}
if src.ToolInput != nil {
return json.Marshal(&src.ToolInput)
}
if src.VulnerabilityInput != nil {
return json.Marshal(&src.VulnerabilityInput)
}
return nil, nil // no data in oneOf schemas
}
// Get the actual instance
func (obj *Entity1) GetActualInstance() interface{} {
if obj == nil {
return nil
}
if obj.AttackPatternInput != nil {
return obj.AttackPatternInput
}
if obj.CampaignInput != nil {
return obj.CampaignInput
}
if obj.CompanyInput != nil {
return obj.CompanyInput
}
if obj.CourseOfActionInput != nil {
return obj.CourseOfActionInput
}
if obj.IdentityInput != nil {
return obj.IdentityInput
}
if obj.IntrusionSetInput != nil {
return obj.IntrusionSetInput
}
if obj.InvestigationInput != nil {
return obj.InvestigationInput
}
if obj.MalwareInput != nil {
return obj.MalwareInput
}
if obj.NoteInput != nil {
return obj.NoteInput
}
if obj.PhoneInput != nil {
return obj.PhoneInput
}
if obj.ThreatActorInput != nil {
return obj.ThreatActorInput
}
if obj.ToolInput != nil {
return obj.ToolInput
}
if obj.VulnerabilityInput != nil {
return obj.VulnerabilityInput
}
// all schemas are nil
return nil
}
type NullableEntity1 struct {
value *Entity1
isSet bool
}
func (v NullableEntity1) Get() *Entity1 {
return v.value
}
func (v *NullableEntity1) Set(val *Entity1) {
v.value = val
v.isSet = true
}
func (v NullableEntity1) IsSet() bool {
return v.isSet
}
func (v *NullableEntity1) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableEntity1(val *Entity1) *NullableEntity1 {
return &NullableEntity1{value: val, isSet: true}
}
func (v NullableEntity1) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableEntity1) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}