blob: a047d7735f55057a348595817fe7352027dfc1db [file] [log] [blame]
Serge Bazanskicc25bdf2018-10-25 14:02:58 +02001// Code generated by go-swagger; DO NOT EDIT.
2
3// Copyright 2018 The go-netbox Authors.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
17package models
18
19// This file was generated by the swagger tool.
20// Editing this file might prove futile when you re-run the swagger generate command
21
22import (
23 "encoding/json"
24
25 strfmt "github.com/go-openapi/strfmt"
26
27 "github.com/go-openapi/errors"
28 "github.com/go-openapi/swag"
29 "github.com/go-openapi/validate"
30)
31
32// WritableDevice writable device
33// swagger:model WritableDevice
34type WritableDevice struct {
35
36 // Asset tag
37 //
38 // A unique tag used to identify this device
39 // Max Length: 50
40 AssetTag string `json:"asset_tag,omitempty"`
41
42 // Cluster
43 Cluster int64 `json:"cluster,omitempty"`
44
45 // Comments
46 Comments string `json:"comments,omitempty"`
47
48 // Created
49 // Read Only: true
50 Created strfmt.Date `json:"created,omitempty"`
51
52 // Custom fields
53 CustomFields interface{} `json:"custom_fields,omitempty"`
54
55 // Device role
56 // Required: true
57 DeviceRole *int64 `json:"device_role"`
58
59 // Device type
60 // Required: true
61 DeviceType *int64 `json:"device_type"`
62
63 // Rack face
64 Face int64 `json:"face,omitempty"`
65
66 // ID
67 // Read Only: true
68 ID int64 `json:"id,omitempty"`
69
70 // Last updated
71 // Read Only: true
72 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"`
73
74 // Name
75 // Max Length: 64
76 Name string `json:"name,omitempty"`
77
78 // Platform
79 Platform int64 `json:"platform,omitempty"`
80
81 // Position (U)
82 //
83 // The lowest-numbered unit occupied by the device
84 // Maximum: 32767
85 // Minimum: 1
86 Position int64 `json:"position,omitempty"`
87
88 // Primary IPv4
89 PrimaryIp4 int64 `json:"primary_ip4,omitempty"`
90
91 // Primary IPv6
92 PrimaryIp6 int64 `json:"primary_ip6,omitempty"`
93
94 // Rack
95 Rack int64 `json:"rack,omitempty"`
96
97 // Serial number
98 // Max Length: 50
99 Serial string `json:"serial,omitempty"`
100
101 // Site
102 // Required: true
103 Site *int64 `json:"site"`
104
105 // Status
106 Status int64 `json:"status,omitempty"`
107
108 // Tenant
109 Tenant int64 `json:"tenant,omitempty"`
110
111 // Vc position
112 // Maximum: 255
113 // Minimum: 0
114 VcPosition *int64 `json:"vc_position,omitempty"`
115
116 // Vc priority
117 // Maximum: 255
118 // Minimum: 0
119 VcPriority *int64 `json:"vc_priority,omitempty"`
120
121 // Virtual chassis
122 VirtualChassis int64 `json:"virtual_chassis,omitempty"`
123}
124
125// Validate validates this writable device
126func (m *WritableDevice) Validate(formats strfmt.Registry) error {
127 var res []error
128
129 if err := m.validateAssetTag(formats); err != nil {
130 // prop
131 res = append(res, err)
132 }
133
134 if err := m.validateDeviceRole(formats); err != nil {
135 // prop
136 res = append(res, err)
137 }
138
139 if err := m.validateDeviceType(formats); err != nil {
140 // prop
141 res = append(res, err)
142 }
143
144 if err := m.validateFace(formats); err != nil {
145 // prop
146 res = append(res, err)
147 }
148
149 if err := m.validateName(formats); err != nil {
150 // prop
151 res = append(res, err)
152 }
153
154 if err := m.validatePosition(formats); err != nil {
155 // prop
156 res = append(res, err)
157 }
158
159 if err := m.validateSerial(formats); err != nil {
160 // prop
161 res = append(res, err)
162 }
163
164 if err := m.validateSite(formats); err != nil {
165 // prop
166 res = append(res, err)
167 }
168
169 if err := m.validateStatus(formats); err != nil {
170 // prop
171 res = append(res, err)
172 }
173
174 if err := m.validateVcPosition(formats); err != nil {
175 // prop
176 res = append(res, err)
177 }
178
179 if err := m.validateVcPriority(formats); err != nil {
180 // prop
181 res = append(res, err)
182 }
183
184 if len(res) > 0 {
185 return errors.CompositeValidationError(res...)
186 }
187 return nil
188}
189
190func (m *WritableDevice) validateAssetTag(formats strfmt.Registry) error {
191
192 if swag.IsZero(m.AssetTag) { // not required
193 return nil
194 }
195
196 if err := validate.MaxLength("asset_tag", "body", string(m.AssetTag), 50); err != nil {
197 return err
198 }
199
200 return nil
201}
202
203func (m *WritableDevice) validateDeviceRole(formats strfmt.Registry) error {
204
205 if err := validate.Required("device_role", "body", m.DeviceRole); err != nil {
206 return err
207 }
208
209 return nil
210}
211
212func (m *WritableDevice) validateDeviceType(formats strfmt.Registry) error {
213
214 if err := validate.Required("device_type", "body", m.DeviceType); err != nil {
215 return err
216 }
217
218 return nil
219}
220
221var writableDeviceTypeFacePropEnum []interface{}
222
223func init() {
224 var res []int64
225 if err := json.Unmarshal([]byte(`[0,1]`), &res); err != nil {
226 panic(err)
227 }
228 for _, v := range res {
229 writableDeviceTypeFacePropEnum = append(writableDeviceTypeFacePropEnum, v)
230 }
231}
232
233// prop value enum
234func (m *WritableDevice) validateFaceEnum(path, location string, value int64) error {
235 if err := validate.Enum(path, location, value, writableDeviceTypeFacePropEnum); err != nil {
236 return err
237 }
238 return nil
239}
240
241func (m *WritableDevice) validateFace(formats strfmt.Registry) error {
242
243 if swag.IsZero(m.Face) { // not required
244 return nil
245 }
246
247 // value enum
248 if err := m.validateFaceEnum("face", "body", m.Face); err != nil {
249 return err
250 }
251
252 return nil
253}
254
255func (m *WritableDevice) validateName(formats strfmt.Registry) error {
256
257 if swag.IsZero(m.Name) { // not required
258 return nil
259 }
260
261 if err := validate.MaxLength("name", "body", string(m.Name), 64); err != nil {
262 return err
263 }
264
265 return nil
266}
267
268func (m *WritableDevice) validatePosition(formats strfmt.Registry) error {
269
270 if swag.IsZero(m.Position) { // not required
271 return nil
272 }
273
274 if err := validate.MinimumInt("position", "body", int64(m.Position), 1, false); err != nil {
275 return err
276 }
277
278 if err := validate.MaximumInt("position", "body", int64(m.Position), 32767, false); err != nil {
279 return err
280 }
281
282 return nil
283}
284
285func (m *WritableDevice) validateSerial(formats strfmt.Registry) error {
286
287 if swag.IsZero(m.Serial) { // not required
288 return nil
289 }
290
291 if err := validate.MaxLength("serial", "body", string(m.Serial), 50); err != nil {
292 return err
293 }
294
295 return nil
296}
297
298func (m *WritableDevice) validateSite(formats strfmt.Registry) error {
299
300 if err := validate.Required("site", "body", m.Site); err != nil {
301 return err
302 }
303
304 return nil
305}
306
307var writableDeviceTypeStatusPropEnum []interface{}
308
309func init() {
310 var res []int64
311 if err := json.Unmarshal([]byte(`[1,0,2,3,4,5]`), &res); err != nil {
312 panic(err)
313 }
314 for _, v := range res {
315 writableDeviceTypeStatusPropEnum = append(writableDeviceTypeStatusPropEnum, v)
316 }
317}
318
319// prop value enum
320func (m *WritableDevice) validateStatusEnum(path, location string, value int64) error {
321 if err := validate.Enum(path, location, value, writableDeviceTypeStatusPropEnum); err != nil {
322 return err
323 }
324 return nil
325}
326
327func (m *WritableDevice) validateStatus(formats strfmt.Registry) error {
328
329 if swag.IsZero(m.Status) { // not required
330 return nil
331 }
332
333 // value enum
334 if err := m.validateStatusEnum("status", "body", m.Status); err != nil {
335 return err
336 }
337
338 return nil
339}
340
341func (m *WritableDevice) validateVcPosition(formats strfmt.Registry) error {
342
343 if swag.IsZero(m.VcPosition) { // not required
344 return nil
345 }
346
347 if err := validate.MinimumInt("vc_position", "body", int64(*m.VcPosition), 0, false); err != nil {
348 return err
349 }
350
351 if err := validate.MaximumInt("vc_position", "body", int64(*m.VcPosition), 255, false); err != nil {
352 return err
353 }
354
355 return nil
356}
357
358func (m *WritableDevice) validateVcPriority(formats strfmt.Registry) error {
359
360 if swag.IsZero(m.VcPriority) { // not required
361 return nil
362 }
363
364 if err := validate.MinimumInt("vc_priority", "body", int64(*m.VcPriority), 0, false); err != nil {
365 return err
366 }
367
368 if err := validate.MaximumInt("vc_priority", "body", int64(*m.VcPriority), 255, false); err != nil {
369 return err
370 }
371
372 return nil
373}
374
375// MarshalBinary interface implementation
376func (m *WritableDevice) MarshalBinary() ([]byte, error) {
377 if m == nil {
378 return nil, nil
379 }
380 return swag.WriteJSON(m)
381}
382
383// UnmarshalBinary interface implementation
384func (m *WritableDevice) UnmarshalBinary(b []byte) error {
385 var res WritableDevice
386 if err := swag.ReadJSON(b, &res); err != nil {
387 return err
388 }
389 *m = res
390 return nil
391}