forked from netbox-community/go-netbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
writable_cable.go
368 lines (282 loc) · 8.44 KB
/
writable_cable.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
// Code generated by go-swagger; DO NOT EDIT.
// Copyright 2018 The go-netbox Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
"reflect"
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// WritableCable writable cable
// swagger:model WritableCable
type WritableCable struct {
// Color
// Max Length: 6
// Pattern: ^[0-9a-f]{6}$
Color string `json:"color,omitempty"`
// ID
// Read Only: true
ID int64 `json:"id,omitempty"`
// Label
// Max Length: 100
Label string `json:"label,omitempty"`
// Length
// Maximum: 32767
// Minimum: 0
Length *int64 `json:"length,omitempty"`
// Length unit
// Enum: [1200 1100 2100 2000]
LengthUnit *int64 `json:"length_unit,omitempty"`
// Status
// Enum: [false true]
Status bool `json:"status,omitempty"`
// Termination a
// Read Only: true
TerminationA map[string]string `json:"termination_a,omitempty"`
// Termination a id
// Required: true
// Maximum: 2.147483647e+09
// Minimum: 0
TerminationAID *int64 `json:"termination_a_id"`
// Termination a type
// Required: true
TerminationAType *string `json:"termination_a_type"`
// Termination b
// Read Only: true
TerminationB map[string]string `json:"termination_b,omitempty"`
// Termination b id
// Required: true
// Maximum: 2.147483647e+09
// Minimum: 0
TerminationBID *int64 `json:"termination_b_id"`
// Termination b type
// Required: true
TerminationBType *string `json:"termination_b_type"`
// Type
// Enum: [1300 1500 1510 1600 1610 1700 1800 1810 3000 3010 3020 3030 3040 3500 3510 3520 3800 5000]
Type *int64 `json:"type,omitempty"`
}
// IsEmpty check struct is empty
func (m *WritableCable) IsEmpty() bool {
return reflect.DeepEqual(*m, WritableCable{})
}
// Validate validates this writable cable
func (m *WritableCable) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateColor(formats); err != nil {
res = append(res, err)
}
if err := m.validateLabel(formats); err != nil {
res = append(res, err)
}
if err := m.validateLength(formats); err != nil {
res = append(res, err)
}
if err := m.validateLengthUnit(formats); err != nil {
res = append(res, err)
}
if err := m.validateStatus(formats); err != nil {
res = append(res, err)
}
if err := m.validateTerminationAID(formats); err != nil {
res = append(res, err)
}
if err := m.validateTerminationAType(formats); err != nil {
res = append(res, err)
}
if err := m.validateTerminationBID(formats); err != nil {
res = append(res, err)
}
if err := m.validateTerminationBType(formats); err != nil {
res = append(res, err)
}
if err := m.validateType(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *WritableCable) validateColor(formats strfmt.Registry) error {
if swag.IsZero(m.Color) { // not required
return nil
}
if err := validate.MaxLength("color", "body", string(m.Color), 6); err != nil {
return err
}
if err := validate.Pattern("color", "body", string(m.Color), `^[0-9a-f]{6}$`); err != nil {
return err
}
return nil
}
func (m *WritableCable) validateLabel(formats strfmt.Registry) error {
if swag.IsZero(m.Label) { // not required
return nil
}
if err := validate.MaxLength("label", "body", string(m.Label), 100); err != nil {
return err
}
return nil
}
func (m *WritableCable) validateLength(formats strfmt.Registry) error {
if swag.IsZero(m.Length) { // not required
return nil
}
if err := validate.MinimumInt("length", "body", int64(*m.Length), 0, false); err != nil {
return err
}
if err := validate.MaximumInt("length", "body", int64(*m.Length), 32767, false); err != nil {
return err
}
return nil
}
var writableCableTypeLengthUnitPropEnum []interface{}
func init() {
var res []int64
if err := json.Unmarshal([]byte(`[1200,1100,2100,2000]`), &res); err != nil {
panic(err)
}
for _, v := range res {
writableCableTypeLengthUnitPropEnum = append(writableCableTypeLengthUnitPropEnum, v)
}
}
// prop value enum
func (m *WritableCable) validateLengthUnitEnum(path, location string, value int64) error {
if err := validate.Enum(path, location, value, writableCableTypeLengthUnitPropEnum); err != nil {
return err
}
return nil
}
func (m *WritableCable) validateLengthUnit(formats strfmt.Registry) error {
if swag.IsZero(m.LengthUnit) { // not required
return nil
}
// value enum
if err := m.validateLengthUnitEnum("length_unit", "body", *m.LengthUnit); err != nil {
return err
}
return nil
}
var writableCableTypeStatusPropEnum []interface{}
func init() {
var res []bool
if err := json.Unmarshal([]byte(`[false,true]`), &res); err != nil {
panic(err)
}
for _, v := range res {
writableCableTypeStatusPropEnum = append(writableCableTypeStatusPropEnum, v)
}
}
// prop value enum
func (m *WritableCable) validateStatusEnum(path, location string, value bool) error {
if err := validate.Enum(path, location, value, writableCableTypeStatusPropEnum); err != nil {
return err
}
return nil
}
func (m *WritableCable) validateStatus(formats strfmt.Registry) error {
if swag.IsZero(m.Status) { // not required
return nil
}
// value enum
if err := m.validateStatusEnum("status", "body", m.Status); err != nil {
return err
}
return nil
}
func (m *WritableCable) validateTerminationAID(formats strfmt.Registry) error {
if err := validate.Required("termination_a_id", "body", m.TerminationAID); err != nil {
return err
}
if err := validate.MinimumInt("termination_a_id", "body", int64(*m.TerminationAID), 0, false); err != nil {
return err
}
if err := validate.MaximumInt("termination_a_id", "body", int64(*m.TerminationAID), 2.147483647e+09, false); err != nil {
return err
}
return nil
}
func (m *WritableCable) validateTerminationAType(formats strfmt.Registry) error {
if err := validate.Required("termination_a_type", "body", m.TerminationAType); err != nil {
return err
}
return nil
}
func (m *WritableCable) validateTerminationBID(formats strfmt.Registry) error {
if err := validate.Required("termination_b_id", "body", m.TerminationBID); err != nil {
return err
}
if err := validate.MinimumInt("termination_b_id", "body", int64(*m.TerminationBID), 0, false); err != nil {
return err
}
if err := validate.MaximumInt("termination_b_id", "body", int64(*m.TerminationBID), 2.147483647e+09, false); err != nil {
return err
}
return nil
}
func (m *WritableCable) validateTerminationBType(formats strfmt.Registry) error {
if err := validate.Required("termination_b_type", "body", m.TerminationBType); err != nil {
return err
}
return nil
}
var writableCableTypeTypePropEnum []interface{}
func init() {
var res []int64
if err := json.Unmarshal([]byte(`[1300,1500,1510,1600,1610,1700,1800,1810,3000,3010,3020,3030,3040,3500,3510,3520,3800,5000]`), &res); err != nil {
panic(err)
}
for _, v := range res {
writableCableTypeTypePropEnum = append(writableCableTypeTypePropEnum, v)
}
}
// prop value enum
func (m *WritableCable) validateTypeEnum(path, location string, value int64) error {
if err := validate.Enum(path, location, value, writableCableTypeTypePropEnum); err != nil {
return err
}
return nil
}
func (m *WritableCable) validateType(formats strfmt.Registry) error {
if swag.IsZero(m.Type) { // not required
return nil
}
// value enum
if err := m.validateTypeEnum("type", "body", *m.Type); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *WritableCable) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *WritableCable) UnmarshalBinary(b []byte) error {
var res WritableCable
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}