blob: b12091a000b75d1af5f5384f49613d42a96772b5 [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// VLAN v l a n
31// swagger:model VLAN
32type VLAN struct {
33
34 // Created
35 // Read Only: true
36 Created strfmt.Date `json:"created,omitempty"`
37
38 // Custom fields
39 CustomFields interface{} `json:"custom_fields,omitempty"`
40
41 // Description
42 // Max Length: 100
43 Description string `json:"description,omitempty"`
44
45 // Display name
46 // Read Only: true
47 DisplayName string `json:"display_name,omitempty"`
48
49 // group
50 // Required: true
51 Group *NestedVLANGroup `json:"group"`
52
53 // ID
54 // Read Only: true
55 ID int64 `json:"id,omitempty"`
56
57 // Last updated
58 // Read Only: true
59 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"`
60
61 // Name
62 // Required: true
63 // Max Length: 64
64 Name *string `json:"name"`
65
66 // role
67 // Required: true
68 Role *NestedRole `json:"role"`
69
70 // site
71 // Required: true
72 Site *NestedSite `json:"site"`
73
74 // status
75 // Required: true
76 Status *VLANStatus `json:"status"`
77
78 // tenant
79 // Required: true
80 Tenant *NestedTenant `json:"tenant"`
81
82 // ID
83 // Required: true
84 // Maximum: 4094
85 // Minimum: 1
86 Vid *int64 `json:"vid"`
87}
88
89// Validate validates this v l a n
90func (m *VLAN) Validate(formats strfmt.Registry) error {
91 var res []error
92
93 if err := m.validateDescription(formats); err != nil {
94 // prop
95 res = append(res, err)
96 }
97
98 if err := m.validateGroup(formats); err != nil {
99 // prop
100 res = append(res, err)
101 }
102
103 if err := m.validateName(formats); err != nil {
104 // prop
105 res = append(res, err)
106 }
107
108 if err := m.validateRole(formats); err != nil {
109 // prop
110 res = append(res, err)
111 }
112
113 if err := m.validateSite(formats); err != nil {
114 // prop
115 res = append(res, err)
116 }
117
118 if err := m.validateStatus(formats); err != nil {
119 // prop
120 res = append(res, err)
121 }
122
123 if err := m.validateTenant(formats); err != nil {
124 // prop
125 res = append(res, err)
126 }
127
128 if err := m.validateVid(formats); err != nil {
129 // prop
130 res = append(res, err)
131 }
132
133 if len(res) > 0 {
134 return errors.CompositeValidationError(res...)
135 }
136 return nil
137}
138
139func (m *VLAN) validateDescription(formats strfmt.Registry) error {
140
141 if swag.IsZero(m.Description) { // not required
142 return nil
143 }
144
145 if err := validate.MaxLength("description", "body", string(m.Description), 100); err != nil {
146 return err
147 }
148
149 return nil
150}
151
152func (m *VLAN) validateGroup(formats strfmt.Registry) error {
153
154 if err := validate.Required("group", "body", m.Group); err != nil {
155 return err
156 }
157
158 if m.Group != nil {
159
160 if err := m.Group.Validate(formats); err != nil {
161 if ve, ok := err.(*errors.Validation); ok {
162 return ve.ValidateName("group")
163 }
164 return err
165 }
166 }
167
168 return nil
169}
170
171func (m *VLAN) validateName(formats strfmt.Registry) error {
172
173 if err := validate.Required("name", "body", m.Name); err != nil {
174 return err
175 }
176
177 if err := validate.MaxLength("name", "body", string(*m.Name), 64); err != nil {
178 return err
179 }
180
181 return nil
182}
183
184func (m *VLAN) validateRole(formats strfmt.Registry) error {
185
186 if err := validate.Required("role", "body", m.Role); err != nil {
187 return err
188 }
189
190 if m.Role != nil {
191
192 if err := m.Role.Validate(formats); err != nil {
193 if ve, ok := err.(*errors.Validation); ok {
194 return ve.ValidateName("role")
195 }
196 return err
197 }
198 }
199
200 return nil
201}
202
203func (m *VLAN) validateSite(formats strfmt.Registry) error {
204
205 if err := validate.Required("site", "body", m.Site); err != nil {
206 return err
207 }
208
209 if m.Site != nil {
210
211 if err := m.Site.Validate(formats); err != nil {
212 if ve, ok := err.(*errors.Validation); ok {
213 return ve.ValidateName("site")
214 }
215 return err
216 }
217 }
218
219 return nil
220}
221
222func (m *VLAN) validateStatus(formats strfmt.Registry) error {
223
224 if err := validate.Required("status", "body", m.Status); err != nil {
225 return err
226 }
227
228 if m.Status != nil {
229
230 if err := m.Status.Validate(formats); err != nil {
231 if ve, ok := err.(*errors.Validation); ok {
232 return ve.ValidateName("status")
233 }
234 return err
235 }
236 }
237
238 return nil
239}
240
241func (m *VLAN) validateTenant(formats strfmt.Registry) error {
242
243 if err := validate.Required("tenant", "body", m.Tenant); err != nil {
244 return err
245 }
246
247 if m.Tenant != nil {
248
249 if err := m.Tenant.Validate(formats); err != nil {
250 if ve, ok := err.(*errors.Validation); ok {
251 return ve.ValidateName("tenant")
252 }
253 return err
254 }
255 }
256
257 return nil
258}
259
260func (m *VLAN) validateVid(formats strfmt.Registry) error {
261
262 if err := validate.Required("vid", "body", m.Vid); err != nil {
263 return err
264 }
265
266 if err := validate.MinimumInt("vid", "body", int64(*m.Vid), 1, false); err != nil {
267 return err
268 }
269
270 if err := validate.MaximumInt("vid", "body", int64(*m.Vid), 4094, false); err != nil {
271 return err
272 }
273
274 return nil
275}
276
277// MarshalBinary interface implementation
278func (m *VLAN) MarshalBinary() ([]byte, error) {
279 if m == nil {
280 return nil, nil
281 }
282 return swag.WriteJSON(m)
283}
284
285// UnmarshalBinary interface implementation
286func (m *VLAN) UnmarshalBinary(b []byte) error {
287 var res VLAN
288 if err := swag.ReadJSON(b, &res); err != nil {
289 return err
290 }
291 *m = res
292 return nil
293}