Repository navigation
Expand file tree
/
Copy pathmodel_asn_range_request_tenant.go
More file actions
178 lines (146 loc) · 4.27 KB
/
Copy pathmodel_asn_range_request_tenant.go
File metadata and controls
178 lines (146 loc) · 4.27 KB
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
/*
NetBox REST API
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
API version: 4.7.2-Docker-5.1.1 (4.7)
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package netbox
import (
"encoding/json"
"fmt"
"gopkg.in/validator.v2"
)
// ASNRangeRequestTenant - struct for ASNRangeRequestTenant
type ASNRangeRequestTenant struct {
BriefTenantRequest *BriefTenantRequest
Int32 *int32
}
// BriefTenantRequestAsASNRangeRequestTenant is a convenience function that returns BriefTenantRequest wrapped in ASNRangeRequestTenant
func BriefTenantRequestAsASNRangeRequestTenant(v *BriefTenantRequest) ASNRangeRequestTenant {
return ASNRangeRequestTenant{
BriefTenantRequest: v,
}
}
// int32AsASNRangeRequestTenant is a convenience function that returns int32 wrapped in ASNRangeRequestTenant
func Int32AsASNRangeRequestTenant(v *int32) ASNRangeRequestTenant {
return ASNRangeRequestTenant{
Int32: v,
}
}
// Unmarshal JSON data into one of the pointers in the struct
func (dst *ASNRangeRequestTenant) UnmarshalJSON(data []byte) error {
var err error
// this object is nullable so check if the payload is null or empty string
if string(data) == "" || string(data) == "{}" {
return nil
}
match := 0
// try to unmarshal data into BriefTenantRequest
err = newStrictDecoder(data).Decode(&dst.BriefTenantRequest)
if err == nil {
jsonBriefTenantRequest, _ := json.Marshal(dst.BriefTenantRequest)
if string(jsonBriefTenantRequest) == "{}" { // empty struct
dst.BriefTenantRequest = nil
} else {
if err = validator.Validate(dst.BriefTenantRequest); err != nil {
dst.BriefTenantRequest = nil
} else {
match++
}
}
} else {
dst.BriefTenantRequest = nil
}
// try to unmarshal data into Int32
err = newStrictDecoder(data).Decode(&dst.Int32)
if err == nil {
jsonInt32, _ := json.Marshal(dst.Int32)
if string(jsonInt32) == "{}" { // empty struct
dst.Int32 = nil
} else {
if err = validator.Validate(dst.Int32); err != nil {
dst.Int32 = nil
} else {
match++
}
}
} else {
dst.Int32 = nil
}
if match > 1 { // more than 1 match
// reset to nil
dst.BriefTenantRequest = nil
dst.Int32 = nil
return fmt.Errorf("data matches more than one schema in oneOf(ASNRangeRequestTenant)")
} else if match == 1 {
return nil // exactly one match
} else { // no match
if err != nil {
return fmt.Errorf("data failed to match schemas in oneOf(ASNRangeRequestTenant): %v", err)
}
return fmt.Errorf("data failed to match schemas in oneOf(ASNRangeRequestTenant)")
}
}
// Marshal data from the first non-nil pointers in the struct to JSON
func (src ASNRangeRequestTenant) MarshalJSON() ([]byte, error) {
if src.BriefTenantRequest != nil {
return json.Marshal(&src.BriefTenantRequest)
}
if src.Int32 != nil {
return json.Marshal(&src.Int32)
}
return nil, nil // no data in oneOf schemas
}
// Get the actual instance
func (obj *ASNRangeRequestTenant) GetActualInstance() interface{} {
if obj == nil {
return nil
}
if obj.BriefTenantRequest != nil {
return obj.BriefTenantRequest
}
if obj.Int32 != nil {
return obj.Int32
}
// all schemas are nil
return nil
}
// Get the actual instance value
func (obj ASNRangeRequestTenant) GetActualInstanceValue() interface{} {
if obj.BriefTenantRequest != nil {
return *obj.BriefTenantRequest
}
if obj.Int32 != nil {
return *obj.Int32
}
// all schemas are nil
return nil
}
type NullableASNRangeRequestTenant struct {
value *ASNRangeRequestTenant
isSet bool
}
func (v NullableASNRangeRequestTenant) Get() *ASNRangeRequestTenant {
return v.value
}
func (v *NullableASNRangeRequestTenant) Set(val *ASNRangeRequestTenant) {
v.value = val
v.isSet = true
}
func (v NullableASNRangeRequestTenant) IsSet() bool {
return v.isSet
}
func (v *NullableASNRangeRequestTenant) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableASNRangeRequestTenant(val *ASNRangeRequestTenant) *NullableASNRangeRequestTenant {
return &NullableASNRangeRequestTenant{value: val, isSet: true}
}
func (v NullableASNRangeRequestTenant) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableASNRangeRequestTenant) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}