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