blob: 85e1c5fd2961ac92d59a85d29f3d0eb6ba4dc05b [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// WritableSite writable site
33// swagger:model WritableSite
34type WritableSite struct {
35
36 // ASN
37 // Maximum: 4.294967295e+09
38 // Minimum: 1
39 Asn int64 `json:"asn,omitempty"`
40
41 // Comments
42 Comments string `json:"comments,omitempty"`
43
44 // Contact E-mail
45 // Max Length: 254
46 ContactEmail strfmt.Email `json:"contact_email,omitempty"`
47
48 // Contact name
49 // Max Length: 50
50 ContactName string `json:"contact_name,omitempty"`
51
52 // Contact phone
53 // Max Length: 20
54 ContactPhone string `json:"contact_phone,omitempty"`
55
56 // Created
57 // Read Only: true
58 Created strfmt.Date `json:"created,omitempty"`
59
60 // Custom fields
61 CustomFields interface{} `json:"custom_fields,omitempty"`
62
63 // Description
64 // Max Length: 100
65 Description string `json:"description,omitempty"`
66
67 // Facility
68 // Max Length: 50
69 Facility string `json:"facility,omitempty"`
70
71 // ID
72 // Read Only: true
73 ID int64 `json:"id,omitempty"`
74
75 // Last updated
76 // Read Only: true
77 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"`
78
79 // Name
80 // Required: true
81 // Max Length: 50
82 Name *string `json:"name"`
83
84 // Physical address
85 // Max Length: 200
86 PhysicalAddress string `json:"physical_address,omitempty"`
87
88 // Region
89 Region int64 `json:"region,omitempty"`
90
91 // Shipping address
92 // Max Length: 200
93 ShippingAddress string `json:"shipping_address,omitempty"`
94
95 // Slug
96 // Required: true
97 // Max Length: 50
98 // Pattern: ^[-a-zA-Z0-9_]+$
99 Slug *string `json:"slug"`
100
101 // Status
102 Status int64 `json:"status,omitempty"`
103
104 // Tenant
105 Tenant int64 `json:"tenant,omitempty"`
106
107 // Time zone
108 TimeZone string `json:"time_zone,omitempty"`
109}
110
111// Validate validates this writable site
112func (m *WritableSite) Validate(formats strfmt.Registry) error {
113 var res []error
114
115 if err := m.validateAsn(formats); err != nil {
116 // prop
117 res = append(res, err)
118 }
119
120 if err := m.validateContactEmail(formats); err != nil {
121 // prop
122 res = append(res, err)
123 }
124
125 if err := m.validateContactName(formats); err != nil {
126 // prop
127 res = append(res, err)
128 }
129
130 if err := m.validateContactPhone(formats); err != nil {
131 // prop
132 res = append(res, err)
133 }
134
135 if err := m.validateDescription(formats); err != nil {
136 // prop
137 res = append(res, err)
138 }
139
140 if err := m.validateFacility(formats); err != nil {
141 // prop
142 res = append(res, err)
143 }
144
145 if err := m.validateName(formats); err != nil {
146 // prop
147 res = append(res, err)
148 }
149
150 if err := m.validatePhysicalAddress(formats); err != nil {
151 // prop
152 res = append(res, err)
153 }
154
155 if err := m.validateShippingAddress(formats); err != nil {
156 // prop
157 res = append(res, err)
158 }
159
160 if err := m.validateSlug(formats); err != nil {
161 // prop
162 res = append(res, err)
163 }
164
165 if err := m.validateStatus(formats); err != nil {
166 // prop
167 res = append(res, err)
168 }
169
170 if len(res) > 0 {
171 return errors.CompositeValidationError(res...)
172 }
173 return nil
174}
175
176func (m *WritableSite) validateAsn(formats strfmt.Registry) error {
177
178 if swag.IsZero(m.Asn) { // not required
179 return nil
180 }
181
182 if err := validate.MinimumInt("asn", "body", int64(m.Asn), 1, false); err != nil {
183 return err
184 }
185
186 if err := validate.MaximumInt("asn", "body", int64(m.Asn), 4.294967295e+09, false); err != nil {
187 return err
188 }
189
190 return nil
191}
192
193func (m *WritableSite) validateContactEmail(formats strfmt.Registry) error {
194
195 if swag.IsZero(m.ContactEmail) { // not required
196 return nil
197 }
198
199 if err := validate.MaxLength("contact_email", "body", string(m.ContactEmail), 254); err != nil {
200 return err
201 }
202
203 if err := validate.FormatOf("contact_email", "body", "email", m.ContactEmail.String(), formats); err != nil {
204 return err
205 }
206
207 return nil
208}
209
210func (m *WritableSite) validateContactName(formats strfmt.Registry) error {
211
212 if swag.IsZero(m.ContactName) { // not required
213 return nil
214 }
215
216 if err := validate.MaxLength("contact_name", "body", string(m.ContactName), 50); err != nil {
217 return err
218 }
219
220 return nil
221}
222
223func (m *WritableSite) validateContactPhone(formats strfmt.Registry) error {
224
225 if swag.IsZero(m.ContactPhone) { // not required
226 return nil
227 }
228
229 if err := validate.MaxLength("contact_phone", "body", string(m.ContactPhone), 20); err != nil {
230 return err
231 }
232
233 return nil
234}
235
236func (m *WritableSite) validateDescription(formats strfmt.Registry) error {
237
238 if swag.IsZero(m.Description) { // not required
239 return nil
240 }
241
242 if err := validate.MaxLength("description", "body", string(m.Description), 100); err != nil {
243 return err
244 }
245
246 return nil
247}
248
249func (m *WritableSite) validateFacility(formats strfmt.Registry) error {
250
251 if swag.IsZero(m.Facility) { // not required
252 return nil
253 }
254
255 if err := validate.MaxLength("facility", "body", string(m.Facility), 50); err != nil {
256 return err
257 }
258
259 return nil
260}
261
262func (m *WritableSite) validateName(formats strfmt.Registry) error {
263
264 if err := validate.Required("name", "body", m.Name); err != nil {
265 return err
266 }
267
268 if err := validate.MaxLength("name", "body", string(*m.Name), 50); err != nil {
269 return err
270 }
271
272 return nil
273}
274
275func (m *WritableSite) validatePhysicalAddress(formats strfmt.Registry) error {
276
277 if swag.IsZero(m.PhysicalAddress) { // not required
278 return nil
279 }
280
281 if err := validate.MaxLength("physical_address", "body", string(m.PhysicalAddress), 200); err != nil {
282 return err
283 }
284
285 return nil
286}
287
288func (m *WritableSite) validateShippingAddress(formats strfmt.Registry) error {
289
290 if swag.IsZero(m.ShippingAddress) { // not required
291 return nil
292 }
293
294 if err := validate.MaxLength("shipping_address", "body", string(m.ShippingAddress), 200); err != nil {
295 return err
296 }
297
298 return nil
299}
300
301func (m *WritableSite) validateSlug(formats strfmt.Registry) error {
302
303 if err := validate.Required("slug", "body", m.Slug); err != nil {
304 return err
305 }
306
307 if err := validate.MaxLength("slug", "body", string(*m.Slug), 50); err != nil {
308 return err
309 }
310
311 if err := validate.Pattern("slug", "body", string(*m.Slug), `^[-a-zA-Z0-9_]+$`); err != nil {
312 return err
313 }
314
315 return nil
316}
317
318var writableSiteTypeStatusPropEnum []interface{}
319
320func init() {
321 var res []int64
322 if err := json.Unmarshal([]byte(`[1,2,4]`), &res); err != nil {
323 panic(err)
324 }
325 for _, v := range res {
326 writableSiteTypeStatusPropEnum = append(writableSiteTypeStatusPropEnum, v)
327 }
328}
329
330// prop value enum
331func (m *WritableSite) validateStatusEnum(path, location string, value int64) error {
332 if err := validate.Enum(path, location, value, writableSiteTypeStatusPropEnum); err != nil {
333 return err
334 }
335 return nil
336}
337
338func (m *WritableSite) validateStatus(formats strfmt.Registry) error {
339
340 if swag.IsZero(m.Status) { // not required
341 return nil
342 }
343
344 // value enum
345 if err := m.validateStatusEnum("status", "body", m.Status); err != nil {
346 return err
347 }
348
349 return nil
350}
351
352// MarshalBinary interface implementation
353func (m *WritableSite) MarshalBinary() ([]byte, error) {
354 if m == nil {
355 return nil, nil
356 }
357 return swag.WriteJSON(m)
358}
359
360// UnmarshalBinary interface implementation
361func (m *WritableSite) UnmarshalBinary(b []byte) error {
362 var res WritableSite
363 if err := swag.ReadJSON(b, &res); err != nil {
364 return err
365 }
366 *m = res
367 return nil
368}