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