forked from nautobot/go-nautobot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
model_bulk_writable_external_integration_request_http_method.go
157 lines (128 loc) · 4.53 KB
/
model_bulk_writable_external_integration_request_http_method.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.2 (2.3)
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package nautobot
import (
"encoding/json"
"gopkg.in/validator.v2"
"fmt"
)
// BulkWritableExternalIntegrationRequestHttpMethod - struct for BulkWritableExternalIntegrationRequestHttpMethod
type BulkWritableExternalIntegrationRequestHttpMethod struct {
BlankEnum *BlankEnum
HttpMethodEnum *HttpMethodEnum
}
// BlankEnumAsBulkWritableExternalIntegrationRequestHttpMethod is a convenience function that returns BlankEnum wrapped in BulkWritableExternalIntegrationRequestHttpMethod
func BlankEnumAsBulkWritableExternalIntegrationRequestHttpMethod(v *BlankEnum) BulkWritableExternalIntegrationRequestHttpMethod {
return BulkWritableExternalIntegrationRequestHttpMethod{
BlankEnum: v,
}
}
// HttpMethodEnumAsBulkWritableExternalIntegrationRequestHttpMethod is a convenience function that returns HttpMethodEnum wrapped in BulkWritableExternalIntegrationRequestHttpMethod
func HttpMethodEnumAsBulkWritableExternalIntegrationRequestHttpMethod(v *HttpMethodEnum) BulkWritableExternalIntegrationRequestHttpMethod {
return BulkWritableExternalIntegrationRequestHttpMethod{
HttpMethodEnum: v,
}
}
// Unmarshal JSON data into one of the pointers in the struct
func (dst *BulkWritableExternalIntegrationRequestHttpMethod) 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 HttpMethodEnum
err = newStrictDecoder(data).Decode(&dst.HttpMethodEnum)
if err == nil {
jsonHttpMethodEnum, _ := json.Marshal(dst.HttpMethodEnum)
if string(jsonHttpMethodEnum) == "{}" { // empty struct
dst.HttpMethodEnum = nil
} else {
if err = validator.Validate(dst.HttpMethodEnum); err != nil {
dst.HttpMethodEnum = nil
} else {
match++
}
}
} else {
dst.HttpMethodEnum = nil
}
if match > 1 { // more than 1 match
// reset to nil
dst.BlankEnum = nil
dst.HttpMethodEnum = nil
return fmt.Errorf("data matches more than one schema in oneOf(BulkWritableExternalIntegrationRequestHttpMethod)")
} else if match == 1 {
return nil // exactly one match
} else { // no match
return fmt.Errorf("data failed to match schemas in oneOf(BulkWritableExternalIntegrationRequestHttpMethod)")
}
}
// Marshal data from the first non-nil pointers in the struct to JSON
func (src BulkWritableExternalIntegrationRequestHttpMethod) MarshalJSON() ([]byte, error) {
if src.BlankEnum != nil {
return json.Marshal(&src.BlankEnum)
}
if src.HttpMethodEnum != nil {
return json.Marshal(&src.HttpMethodEnum)
}
return nil, nil // no data in oneOf schemas
}
// Get the actual instance
func (obj *BulkWritableExternalIntegrationRequestHttpMethod) GetActualInstance() (interface{}) {
if obj == nil {
return nil
}
if obj.BlankEnum != nil {
return obj.BlankEnum
}
if obj.HttpMethodEnum != nil {
return obj.HttpMethodEnum
}
// all schemas are nil
return nil
}
type NullableBulkWritableExternalIntegrationRequestHttpMethod struct {
value *BulkWritableExternalIntegrationRequestHttpMethod
isSet bool
}
func (v NullableBulkWritableExternalIntegrationRequestHttpMethod) Get() *BulkWritableExternalIntegrationRequestHttpMethod {
return v.value
}
func (v *NullableBulkWritableExternalIntegrationRequestHttpMethod) Set(val *BulkWritableExternalIntegrationRequestHttpMethod) {
v.value = val
v.isSet = true
}
func (v NullableBulkWritableExternalIntegrationRequestHttpMethod) IsSet() bool {
return v.isSet
}
func (v *NullableBulkWritableExternalIntegrationRequestHttpMethod) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableBulkWritableExternalIntegrationRequestHttpMethod(val *BulkWritableExternalIntegrationRequestHttpMethod) *NullableBulkWritableExternalIntegrationRequestHttpMethod {
return &NullableBulkWritableExternalIntegrationRequestHttpMethod{value: val, isSet: true}
}
func (v NullableBulkWritableExternalIntegrationRequestHttpMethod) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableBulkWritableExternalIntegrationRequestHttpMethod) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}