forked from netbox-community/go-netbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
writable_front_port.go
268 lines (203 loc) · 5.85 KB
/
writable_front_port.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
// 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"
"strconv"
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// WritableFrontPort writable front port
// swagger:model WritableFrontPort
type WritableFrontPort struct {
// cable
Cable *NestedCable `json:"cable,omitempty"`
// Description
// Max Length: 100
Description string `json:"description,omitempty"`
// Device
// Required: true
Device *int64 `json:"device"`
// ID
// Read Only: true
ID int64 `json:"id,omitempty"`
// Name
// Required: true
// Max Length: 64
// Min Length: 1
Name *string `json:"name"`
// Rear port
// Required: true
RearPort *int64 `json:"rear_port"`
// Rear port position
// Maximum: 64
// Minimum: 1
RearPortPosition int64 `json:"rear_port_position,omitempty"`
// tags
Tags []string `json:"tags"`
// Type
// Required: true
// Enum: [1000 1100 2200 2300 2310 2600 2610 2500 2400 2100 2110 2000]
Type *int64 `json:"type"`
}
// Validate validates this writable front port
func (m *WritableFrontPort) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCable(formats); err != nil {
res = append(res, err)
}
if err := m.validateDescription(formats); err != nil {
res = append(res, err)
}
if err := m.validateDevice(formats); err != nil {
res = append(res, err)
}
if err := m.validateName(formats); err != nil {
res = append(res, err)
}
if err := m.validateRearPort(formats); err != nil {
res = append(res, err)
}
if err := m.validateRearPortPosition(formats); err != nil {
res = append(res, err)
}
if err := m.validateTags(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 *WritableFrontPort) validateCable(formats strfmt.Registry) error {
if swag.IsZero(m.Cable) { // not required
return nil
}
if m.Cable != nil {
if err := m.Cable.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("cable")
}
return err
}
}
return nil
}
func (m *WritableFrontPort) validateDescription(formats strfmt.Registry) error {
if swag.IsZero(m.Description) { // not required
return nil
}
if err := validate.MaxLength("description", "body", string(m.Description), 100); err != nil {
return err
}
return nil
}
func (m *WritableFrontPort) validateDevice(formats strfmt.Registry) error {
if err := validate.Required("device", "body", m.Device); err != nil {
return err
}
return nil
}
func (m *WritableFrontPort) validateName(formats strfmt.Registry) error {
if err := validate.Required("name", "body", m.Name); err != nil {
return err
}
if err := validate.MinLength("name", "body", string(*m.Name), 1); err != nil {
return err
}
if err := validate.MaxLength("name", "body", string(*m.Name), 64); err != nil {
return err
}
return nil
}
func (m *WritableFrontPort) validateRearPort(formats strfmt.Registry) error {
if err := validate.Required("rear_port", "body", m.RearPort); err != nil {
return err
}
return nil
}
func (m *WritableFrontPort) validateRearPortPosition(formats strfmt.Registry) error {
if swag.IsZero(m.RearPortPosition) { // not required
return nil
}
if err := validate.MinimumInt("rear_port_position", "body", int64(m.RearPortPosition), 1, false); err != nil {
return err
}
if err := validate.MaximumInt("rear_port_position", "body", int64(m.RearPortPosition), 64, false); err != nil {
return err
}
return nil
}
func (m *WritableFrontPort) validateTags(formats strfmt.Registry) error {
if swag.IsZero(m.Tags) { // not required
return nil
}
for i := 0; i < len(m.Tags); i++ {
if err := validate.MinLength("tags"+"."+strconv.Itoa(i), "body", string(m.Tags[i]), 1); err != nil {
return err
}
}
return nil
}
var writableFrontPortTypeTypePropEnum []interface{}
func init() {
var res []int64
if err := json.Unmarshal([]byte(`[1000,1100,2200,2300,2310,2600,2610,2500,2400,2100,2110,2000]`), &res); err != nil {
panic(err)
}
for _, v := range res {
writableFrontPortTypeTypePropEnum = append(writableFrontPortTypeTypePropEnum, v)
}
}
// prop value enum
func (m *WritableFrontPort) validateTypeEnum(path, location string, value int64) error {
if err := validate.Enum(path, location, value, writableFrontPortTypeTypePropEnum); err != nil {
return err
}
return nil
}
func (m *WritableFrontPort) validateType(formats strfmt.Registry) error {
if err := validate.Required("type", "body", m.Type); err != nil {
return err
}
// value enum
if err := m.validateTypeEnum("type", "body", *m.Type); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *WritableFrontPort) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *WritableFrontPort) UnmarshalBinary(b []byte) error {
var res WritableFrontPort
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}