blob: e6c167a8e1b94eb39876cab63548d216313b9e48 [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 strfmt "github.com/go-openapi/strfmt"
24
25 "github.com/go-openapi/errors"
26 "github.com/go-openapi/swag"
27 "github.com/go-openapi/validate"
28)
29
30// DeviceType device type
31// swagger:model DeviceType
32type DeviceType struct {
33
34 // Comments
35 Comments string `json:"comments,omitempty"`
36
37 // Custom fields
38 CustomFields interface{} `json:"custom_fields,omitempty"`
39
40 // ID
41 // Read Only: true
42 ID int64 `json:"id,omitempty"`
43
44 // Instance count
45 // Read Only: true
46 InstanceCount int64 `json:"instance_count,omitempty"`
47
48 // interface ordering
49 // Required: true
50 InterfaceOrdering *DeviceTypeInterfaceOrdering `json:"interface_ordering"`
51
52 // Is a console server
53 //
54 // This type of device has console server ports
55 IsConsoleServer bool `json:"is_console_server,omitempty"`
56
57 // Is full depth
58 //
59 // Device consumes both front and rear rack faces
60 IsFullDepth bool `json:"is_full_depth,omitempty"`
61
62 // Is a network device
63 //
64 // This type of device has network interfaces
65 IsNetworkDevice bool `json:"is_network_device,omitempty"`
66
67 // Is a PDU
68 //
69 // This type of device has power outlets
70 IsPdu bool `json:"is_pdu,omitempty"`
71
72 // manufacturer
73 // Required: true
74 Manufacturer *NestedManufacturer `json:"manufacturer"`
75
76 // Model
77 // Required: true
78 // Max Length: 50
79 Model *string `json:"model"`
80
81 // Part number
82 //
83 // Discrete part number (optional)
84 // Max Length: 50
85 PartNumber string `json:"part_number,omitempty"`
86
87 // Slug
88 // Required: true
89 // Max Length: 50
90 // Pattern: ^[-a-zA-Z0-9_]+$
91 Slug *string `json:"slug"`
92
93 // subdevice role
94 // Required: true
95 SubdeviceRole *DeviceTypeSubdeviceRole `json:"subdevice_role"`
96
97 // Height (U)
98 // Maximum: 32767
99 // Minimum: 0
100 UHeight *int64 `json:"u_height,omitempty"`
101}
102
103// Validate validates this device type
104func (m *DeviceType) Validate(formats strfmt.Registry) error {
105 var res []error
106
107 if err := m.validateInterfaceOrdering(formats); err != nil {
108 // prop
109 res = append(res, err)
110 }
111
112 if err := m.validateManufacturer(formats); err != nil {
113 // prop
114 res = append(res, err)
115 }
116
117 if err := m.validateModel(formats); err != nil {
118 // prop
119 res = append(res, err)
120 }
121
122 if err := m.validatePartNumber(formats); err != nil {
123 // prop
124 res = append(res, err)
125 }
126
127 if err := m.validateSlug(formats); err != nil {
128 // prop
129 res = append(res, err)
130 }
131
132 if err := m.validateSubdeviceRole(formats); err != nil {
133 // prop
134 res = append(res, err)
135 }
136
137 if err := m.validateUHeight(formats); err != nil {
138 // prop
139 res = append(res, err)
140 }
141
142 if len(res) > 0 {
143 return errors.CompositeValidationError(res...)
144 }
145 return nil
146}
147
148func (m *DeviceType) validateInterfaceOrdering(formats strfmt.Registry) error {
149
150 if err := validate.Required("interface_ordering", "body", m.InterfaceOrdering); err != nil {
151 return err
152 }
153
154 if m.InterfaceOrdering != nil {
155
156 if err := m.InterfaceOrdering.Validate(formats); err != nil {
157 if ve, ok := err.(*errors.Validation); ok {
158 return ve.ValidateName("interface_ordering")
159 }
160 return err
161 }
162 }
163
164 return nil
165}
166
167func (m *DeviceType) validateManufacturer(formats strfmt.Registry) error {
168
169 if err := validate.Required("manufacturer", "body", m.Manufacturer); err != nil {
170 return err
171 }
172
173 if m.Manufacturer != nil {
174
175 if err := m.Manufacturer.Validate(formats); err != nil {
176 if ve, ok := err.(*errors.Validation); ok {
177 return ve.ValidateName("manufacturer")
178 }
179 return err
180 }
181 }
182
183 return nil
184}
185
186func (m *DeviceType) validateModel(formats strfmt.Registry) error {
187
188 if err := validate.Required("model", "body", m.Model); err != nil {
189 return err
190 }
191
192 if err := validate.MaxLength("model", "body", string(*m.Model), 50); err != nil {
193 return err
194 }
195
196 return nil
197}
198
199func (m *DeviceType) validatePartNumber(formats strfmt.Registry) error {
200
201 if swag.IsZero(m.PartNumber) { // not required
202 return nil
203 }
204
205 if err := validate.MaxLength("part_number", "body", string(m.PartNumber), 50); err != nil {
206 return err
207 }
208
209 return nil
210}
211
212func (m *DeviceType) validateSlug(formats strfmt.Registry) error {
213
214 if err := validate.Required("slug", "body", m.Slug); err != nil {
215 return err
216 }
217
218 if err := validate.MaxLength("slug", "body", string(*m.Slug), 50); err != nil {
219 return err
220 }
221
222 if err := validate.Pattern("slug", "body", string(*m.Slug), `^[-a-zA-Z0-9_]+$`); err != nil {
223 return err
224 }
225
226 return nil
227}
228
229func (m *DeviceType) validateSubdeviceRole(formats strfmt.Registry) error {
230
231 if err := validate.Required("subdevice_role", "body", m.SubdeviceRole); err != nil {
232 return err
233 }
234
235 if m.SubdeviceRole != nil {
236
237 if err := m.SubdeviceRole.Validate(formats); err != nil {
238 if ve, ok := err.(*errors.Validation); ok {
239 return ve.ValidateName("subdevice_role")
240 }
241 return err
242 }
243 }
244
245 return nil
246}
247
248func (m *DeviceType) validateUHeight(formats strfmt.Registry) error {
249
250 if swag.IsZero(m.UHeight) { // not required
251 return nil
252 }
253
254 if err := validate.MinimumInt("u_height", "body", int64(*m.UHeight), 0, false); err != nil {
255 return err
256 }
257
258 if err := validate.MaximumInt("u_height", "body", int64(*m.UHeight), 32767, false); err != nil {
259 return err
260 }
261
262 return nil
263}
264
265// MarshalBinary interface implementation
266func (m *DeviceType) MarshalBinary() ([]byte, error) {
267 if m == nil {
268 return nil, nil
269 }
270 return swag.WriteJSON(m)
271}
272
273// UnmarshalBinary interface implementation
274func (m *DeviceType) UnmarshalBinary(b []byte) error {
275 var res DeviceType
276 if err := swag.ReadJSON(b, &res); err != nil {
277 return err
278 }
279 *m = res
280 return nil
281}