-
Notifications
You must be signed in to change notification settings - Fork 3
/
model_bulk_writable_device_redundancy_group_request_failover_strategy.go
157 lines (128 loc) · 4.9 KB
/
model_bulk_writable_device_redundancy_group_request_failover_strategy.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
/*
API Documentation
Source of truth and network automation platform
API version: 2.3.4 (2.3)
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package nautobot
import (
"encoding/json"
"gopkg.in/validator.v2"
"fmt"
)
// BulkWritableDeviceRedundancyGroupRequestFailoverStrategy - struct for BulkWritableDeviceRedundancyGroupRequestFailoverStrategy
type BulkWritableDeviceRedundancyGroupRequestFailoverStrategy struct {
BlankEnum *BlankEnum
FailoverStrategyEnum *FailoverStrategyEnum
}
// BlankEnumAsBulkWritableDeviceRedundancyGroupRequestFailoverStrategy is a convenience function that returns BlankEnum wrapped in BulkWritableDeviceRedundancyGroupRequestFailoverStrategy
func BlankEnumAsBulkWritableDeviceRedundancyGroupRequestFailoverStrategy(v *BlankEnum) BulkWritableDeviceRedundancyGroupRequestFailoverStrategy {
return BulkWritableDeviceRedundancyGroupRequestFailoverStrategy{
BlankEnum: v,
}
}
// FailoverStrategyEnumAsBulkWritableDeviceRedundancyGroupRequestFailoverStrategy is a convenience function that returns FailoverStrategyEnum wrapped in BulkWritableDeviceRedundancyGroupRequestFailoverStrategy
func FailoverStrategyEnumAsBulkWritableDeviceRedundancyGroupRequestFailoverStrategy(v *FailoverStrategyEnum) BulkWritableDeviceRedundancyGroupRequestFailoverStrategy {
return BulkWritableDeviceRedundancyGroupRequestFailoverStrategy{
FailoverStrategyEnum: v,
}
}
// Unmarshal JSON data into one of the pointers in the struct
func (dst *BulkWritableDeviceRedundancyGroupRequestFailoverStrategy) UnmarshalJSON(data []byte) error {
var err error
match := 0
// try to unmarshal data into BlankEnum
err = newStrictDecoder(data).Decode(&dst.BlankEnum)
if err == nil {
jsonBlankEnum, _ := json.Marshal(dst.BlankEnum)
if string(jsonBlankEnum) == "{}" { // empty struct
dst.BlankEnum = nil
} else {
if err = validator.Validate(dst.BlankEnum); err != nil {
dst.BlankEnum = nil
} else {
match++
}
}
} else {
dst.BlankEnum = nil
}
// try to unmarshal data into FailoverStrategyEnum
err = newStrictDecoder(data).Decode(&dst.FailoverStrategyEnum)
if err == nil {
jsonFailoverStrategyEnum, _ := json.Marshal(dst.FailoverStrategyEnum)
if string(jsonFailoverStrategyEnum) == "{}" { // empty struct
dst.FailoverStrategyEnum = nil
} else {
if err = validator.Validate(dst.FailoverStrategyEnum); err != nil {
dst.FailoverStrategyEnum = nil
} else {
match++
}
}
} else {
dst.FailoverStrategyEnum = nil
}
if match > 1 { // more than 1 match
// reset to nil
dst.BlankEnum = nil
dst.FailoverStrategyEnum = nil
return fmt.Errorf("data matches more than one schema in oneOf(BulkWritableDeviceRedundancyGroupRequestFailoverStrategy)")
} else if match == 1 {
return nil // exactly one match
} else { // no match
return fmt.Errorf("data failed to match schemas in oneOf(BulkWritableDeviceRedundancyGroupRequestFailoverStrategy)")
}
}
// Marshal data from the first non-nil pointers in the struct to JSON
func (src BulkWritableDeviceRedundancyGroupRequestFailoverStrategy) MarshalJSON() ([]byte, error) {
if src.BlankEnum != nil {
return json.Marshal(&src.BlankEnum)
}
if src.FailoverStrategyEnum != nil {
return json.Marshal(&src.FailoverStrategyEnum)
}
return nil, nil // no data in oneOf schemas
}
// Get the actual instance
func (obj *BulkWritableDeviceRedundancyGroupRequestFailoverStrategy) GetActualInstance() (interface{}) {
if obj == nil {
return nil
}
if obj.BlankEnum != nil {
return obj.BlankEnum
}
if obj.FailoverStrategyEnum != nil {
return obj.FailoverStrategyEnum
}
// all schemas are nil
return nil
}
type NullableBulkWritableDeviceRedundancyGroupRequestFailoverStrategy struct {
value *BulkWritableDeviceRedundancyGroupRequestFailoverStrategy
isSet bool
}
func (v NullableBulkWritableDeviceRedundancyGroupRequestFailoverStrategy) Get() *BulkWritableDeviceRedundancyGroupRequestFailoverStrategy {
return v.value
}
func (v *NullableBulkWritableDeviceRedundancyGroupRequestFailoverStrategy) Set(val *BulkWritableDeviceRedundancyGroupRequestFailoverStrategy) {
v.value = val
v.isSet = true
}
func (v NullableBulkWritableDeviceRedundancyGroupRequestFailoverStrategy) IsSet() bool {
return v.isSet
}
func (v *NullableBulkWritableDeviceRedundancyGroupRequestFailoverStrategy) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableBulkWritableDeviceRedundancyGroupRequestFailoverStrategy(val *BulkWritableDeviceRedundancyGroupRequestFailoverStrategy) *NullableBulkWritableDeviceRedundancyGroupRequestFailoverStrategy {
return &NullableBulkWritableDeviceRedundancyGroupRequestFailoverStrategy{value: val, isSet: true}
}
func (v NullableBulkWritableDeviceRedundancyGroupRequestFailoverStrategy) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableBulkWritableDeviceRedundancyGroupRequestFailoverStrategy) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}