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 | // Device device |
| 31 | // swagger:model Device |
| 32 | type Device struct { |
| 33 | |
| 34 | // Asset tag |
| 35 | // |
| 36 | // A unique tag used to identify this device |
| 37 | // Max Length: 50 |
| 38 | AssetTag string `json:"asset_tag,omitempty"` |
| 39 | |
| 40 | // cluster |
| 41 | // Required: true |
| 42 | Cluster *NestedCluster `json:"cluster"` |
| 43 | |
| 44 | // Comments |
| 45 | Comments string `json:"comments,omitempty"` |
| 46 | |
| 47 | // Created |
| 48 | // Read Only: true |
| 49 | Created strfmt.Date `json:"created,omitempty"` |
| 50 | |
| 51 | // Custom fields |
| 52 | CustomFields interface{} `json:"custom_fields,omitempty"` |
| 53 | |
| 54 | // device role |
| 55 | // Required: true |
| 56 | DeviceRole *NestedDeviceRole `json:"device_role"` |
| 57 | |
| 58 | // device type |
| 59 | // Required: true |
| 60 | DeviceType *NestedDeviceType `json:"device_type"` |
| 61 | |
| 62 | // Display name |
| 63 | // Read Only: true |
| 64 | DisplayName string `json:"display_name,omitempty"` |
| 65 | |
| 66 | // face |
| 67 | // Required: true |
| 68 | Face *DeviceFace `json:"face"` |
| 69 | |
| 70 | // ID |
| 71 | // Read Only: true |
| 72 | ID int64 `json:"id,omitempty"` |
| 73 | |
| 74 | // Last updated |
| 75 | // Read Only: true |
| 76 | LastUpdated strfmt.DateTime `json:"last_updated,omitempty"` |
| 77 | |
| 78 | // Name |
| 79 | // Max Length: 64 |
| 80 | Name string `json:"name,omitempty"` |
| 81 | |
| 82 | // Parent device |
| 83 | // Read Only: true |
| 84 | ParentDevice string `json:"parent_device,omitempty"` |
| 85 | |
| 86 | // platform |
| 87 | // Required: true |
| 88 | Platform *NestedPlatform `json:"platform"` |
| 89 | |
| 90 | // Position (U) |
| 91 | // |
| 92 | // The lowest-numbered unit occupied by the device |
| 93 | // Required: true |
| 94 | // Maximum: 32767 |
| 95 | // Minimum: 1 |
| 96 | Position *int64 `json:"position"` |
| 97 | |
| 98 | // primary ip |
| 99 | // Required: true |
| 100 | PrimaryIP *DeviceIPAddress `json:"primary_ip"` |
| 101 | |
| 102 | // primary ip4 |
| 103 | // Required: true |
| 104 | PrimaryIp4 *DeviceIPAddress `json:"primary_ip4"` |
| 105 | |
| 106 | // primary ip6 |
| 107 | // Required: true |
| 108 | PrimaryIp6 *DeviceIPAddress `json:"primary_ip6"` |
| 109 | |
| 110 | // rack |
| 111 | // Required: true |
| 112 | Rack *NestedRack `json:"rack"` |
| 113 | |
| 114 | // Serial number |
| 115 | // Max Length: 50 |
| 116 | Serial string `json:"serial,omitempty"` |
| 117 | |
| 118 | // site |
| 119 | // Required: true |
| 120 | Site *NestedSite `json:"site"` |
| 121 | |
| 122 | // status |
| 123 | // Required: true |
| 124 | Status *DeviceStatus `json:"status"` |
| 125 | |
| 126 | // tenant |
| 127 | // Required: true |
| 128 | Tenant *NestedTenant `json:"tenant"` |
| 129 | |
| 130 | // Vc position |
| 131 | // Required: true |
| 132 | // Maximum: 255 |
| 133 | // Minimum: 0 |
| 134 | VcPosition *int64 `json:"vc_position"` |
| 135 | |
| 136 | // Vc priority |
| 137 | // Maximum: 255 |
| 138 | // Minimum: 0 |
| 139 | VcPriority *int64 `json:"vc_priority,omitempty"` |
| 140 | |
| 141 | // virtual chassis |
| 142 | // Required: true |
| 143 | VirtualChassis *DeviceVirtualChassis `json:"virtual_chassis"` |
| 144 | } |
| 145 | |
| 146 | // Validate validates this device |
| 147 | func (m *Device) Validate(formats strfmt.Registry) error { |
| 148 | var res []error |
| 149 | |
| 150 | if err := m.validateAssetTag(formats); err != nil { |
| 151 | // prop |
| 152 | res = append(res, err) |
| 153 | } |
| 154 | |
| 155 | if err := m.validateCluster(formats); err != nil { |
| 156 | // prop |
| 157 | res = append(res, err) |
| 158 | } |
| 159 | |
| 160 | if err := m.validateDeviceRole(formats); err != nil { |
| 161 | // prop |
| 162 | res = append(res, err) |
| 163 | } |
| 164 | |
| 165 | if err := m.validateDeviceType(formats); err != nil { |
| 166 | // prop |
| 167 | res = append(res, err) |
| 168 | } |
| 169 | |
| 170 | if err := m.validateFace(formats); err != nil { |
| 171 | // prop |
| 172 | res = append(res, err) |
| 173 | } |
| 174 | |
| 175 | if err := m.validateName(formats); err != nil { |
| 176 | // prop |
| 177 | res = append(res, err) |
| 178 | } |
| 179 | |
| 180 | if err := m.validatePlatform(formats); err != nil { |
| 181 | // prop |
| 182 | res = append(res, err) |
| 183 | } |
| 184 | |
| 185 | if err := m.validatePosition(formats); err != nil { |
| 186 | // prop |
| 187 | res = append(res, err) |
| 188 | } |
| 189 | |
| 190 | if err := m.validatePrimaryIP(formats); err != nil { |
| 191 | // prop |
| 192 | res = append(res, err) |
| 193 | } |
| 194 | |
| 195 | if err := m.validatePrimaryIp4(formats); err != nil { |
| 196 | // prop |
| 197 | res = append(res, err) |
| 198 | } |
| 199 | |
| 200 | if err := m.validatePrimaryIp6(formats); err != nil { |
| 201 | // prop |
| 202 | res = append(res, err) |
| 203 | } |
| 204 | |
| 205 | if err := m.validateRack(formats); err != nil { |
| 206 | // prop |
| 207 | res = append(res, err) |
| 208 | } |
| 209 | |
| 210 | if err := m.validateSerial(formats); err != nil { |
| 211 | // prop |
| 212 | res = append(res, err) |
| 213 | } |
| 214 | |
| 215 | if err := m.validateSite(formats); err != nil { |
| 216 | // prop |
| 217 | res = append(res, err) |
| 218 | } |
| 219 | |
| 220 | if err := m.validateStatus(formats); err != nil { |
| 221 | // prop |
| 222 | res = append(res, err) |
| 223 | } |
| 224 | |
| 225 | if err := m.validateTenant(formats); err != nil { |
| 226 | // prop |
| 227 | res = append(res, err) |
| 228 | } |
| 229 | |
| 230 | if err := m.validateVcPosition(formats); err != nil { |
| 231 | // prop |
| 232 | res = append(res, err) |
| 233 | } |
| 234 | |
| 235 | if err := m.validateVcPriority(formats); err != nil { |
| 236 | // prop |
| 237 | res = append(res, err) |
| 238 | } |
| 239 | |
| 240 | if err := m.validateVirtualChassis(formats); err != nil { |
| 241 | // prop |
| 242 | res = append(res, err) |
| 243 | } |
| 244 | |
| 245 | if len(res) > 0 { |
| 246 | return errors.CompositeValidationError(res...) |
| 247 | } |
| 248 | return nil |
| 249 | } |
| 250 | |
| 251 | func (m *Device) validateAssetTag(formats strfmt.Registry) error { |
| 252 | |
| 253 | if swag.IsZero(m.AssetTag) { // not required |
| 254 | return nil |
| 255 | } |
| 256 | |
| 257 | if err := validate.MaxLength("asset_tag", "body", string(m.AssetTag), 50); err != nil { |
| 258 | return err |
| 259 | } |
| 260 | |
| 261 | return nil |
| 262 | } |
| 263 | |
| 264 | func (m *Device) validateCluster(formats strfmt.Registry) error { |
| 265 | |
| 266 | if err := validate.Required("cluster", "body", m.Cluster); err != nil { |
| 267 | return err |
| 268 | } |
| 269 | |
| 270 | if m.Cluster != nil { |
| 271 | |
| 272 | if err := m.Cluster.Validate(formats); err != nil { |
| 273 | if ve, ok := err.(*errors.Validation); ok { |
| 274 | return ve.ValidateName("cluster") |
| 275 | } |
| 276 | return err |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | return nil |
| 281 | } |
| 282 | |
| 283 | func (m *Device) validateDeviceRole(formats strfmt.Registry) error { |
| 284 | |
| 285 | if err := validate.Required("device_role", "body", m.DeviceRole); err != nil { |
| 286 | return err |
| 287 | } |
| 288 | |
| 289 | if m.DeviceRole != nil { |
| 290 | |
| 291 | if err := m.DeviceRole.Validate(formats); err != nil { |
| 292 | if ve, ok := err.(*errors.Validation); ok { |
| 293 | return ve.ValidateName("device_role") |
| 294 | } |
| 295 | return err |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | return nil |
| 300 | } |
| 301 | |
| 302 | func (m *Device) validateDeviceType(formats strfmt.Registry) error { |
| 303 | |
| 304 | if err := validate.Required("device_type", "body", m.DeviceType); err != nil { |
| 305 | return err |
| 306 | } |
| 307 | |
| 308 | if m.DeviceType != nil { |
| 309 | |
| 310 | if err := m.DeviceType.Validate(formats); err != nil { |
| 311 | if ve, ok := err.(*errors.Validation); ok { |
| 312 | return ve.ValidateName("device_type") |
| 313 | } |
| 314 | return err |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | return nil |
| 319 | } |
| 320 | |
| 321 | func (m *Device) validateFace(formats strfmt.Registry) error { |
| 322 | |
| 323 | if err := validate.Required("face", "body", m.Face); err != nil { |
| 324 | return err |
| 325 | } |
| 326 | |
| 327 | if m.Face != nil { |
| 328 | |
| 329 | if err := m.Face.Validate(formats); err != nil { |
| 330 | if ve, ok := err.(*errors.Validation); ok { |
| 331 | return ve.ValidateName("face") |
| 332 | } |
| 333 | return err |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | return nil |
| 338 | } |
| 339 | |
| 340 | func (m *Device) validateName(formats strfmt.Registry) error { |
| 341 | |
| 342 | if swag.IsZero(m.Name) { // not required |
| 343 | return nil |
| 344 | } |
| 345 | |
| 346 | if err := validate.MaxLength("name", "body", string(m.Name), 64); err != nil { |
| 347 | return err |
| 348 | } |
| 349 | |
| 350 | return nil |
| 351 | } |
| 352 | |
| 353 | func (m *Device) validatePlatform(formats strfmt.Registry) error { |
| 354 | |
| 355 | if err := validate.Required("platform", "body", m.Platform); err != nil { |
| 356 | return err |
| 357 | } |
| 358 | |
| 359 | if m.Platform != nil { |
| 360 | |
| 361 | if err := m.Platform.Validate(formats); err != nil { |
| 362 | if ve, ok := err.(*errors.Validation); ok { |
| 363 | return ve.ValidateName("platform") |
| 364 | } |
| 365 | return err |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | return nil |
| 370 | } |
| 371 | |
| 372 | func (m *Device) validatePosition(formats strfmt.Registry) error { |
| 373 | |
| 374 | if err := validate.Required("position", "body", m.Position); err != nil { |
| 375 | return err |
| 376 | } |
| 377 | |
| 378 | if err := validate.MinimumInt("position", "body", int64(*m.Position), 1, false); err != nil { |
| 379 | return err |
| 380 | } |
| 381 | |
| 382 | if err := validate.MaximumInt("position", "body", int64(*m.Position), 32767, false); err != nil { |
| 383 | return err |
| 384 | } |
| 385 | |
| 386 | return nil |
| 387 | } |
| 388 | |
| 389 | func (m *Device) validatePrimaryIP(formats strfmt.Registry) error { |
| 390 | |
| 391 | if err := validate.Required("primary_ip", "body", m.PrimaryIP); err != nil { |
| 392 | return err |
| 393 | } |
| 394 | |
| 395 | if m.PrimaryIP != nil { |
| 396 | |
| 397 | if err := m.PrimaryIP.Validate(formats); err != nil { |
| 398 | if ve, ok := err.(*errors.Validation); ok { |
| 399 | return ve.ValidateName("primary_ip") |
| 400 | } |
| 401 | return err |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | return nil |
| 406 | } |
| 407 | |
| 408 | func (m *Device) validatePrimaryIp4(formats strfmt.Registry) error { |
| 409 | |
| 410 | if err := validate.Required("primary_ip4", "body", m.PrimaryIp4); err != nil { |
| 411 | return err |
| 412 | } |
| 413 | |
| 414 | if m.PrimaryIp4 != nil { |
| 415 | |
| 416 | if err := m.PrimaryIp4.Validate(formats); err != nil { |
| 417 | if ve, ok := err.(*errors.Validation); ok { |
| 418 | return ve.ValidateName("primary_ip4") |
| 419 | } |
| 420 | return err |
| 421 | } |
| 422 | } |
| 423 | |
| 424 | return nil |
| 425 | } |
| 426 | |
| 427 | func (m *Device) validatePrimaryIp6(formats strfmt.Registry) error { |
| 428 | |
| 429 | if err := validate.Required("primary_ip6", "body", m.PrimaryIp6); err != nil { |
| 430 | return err |
| 431 | } |
| 432 | |
| 433 | if m.PrimaryIp6 != nil { |
| 434 | |
| 435 | if err := m.PrimaryIp6.Validate(formats); err != nil { |
| 436 | if ve, ok := err.(*errors.Validation); ok { |
| 437 | return ve.ValidateName("primary_ip6") |
| 438 | } |
| 439 | return err |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | return nil |
| 444 | } |
| 445 | |
| 446 | func (m *Device) validateRack(formats strfmt.Registry) error { |
| 447 | |
| 448 | if err := validate.Required("rack", "body", m.Rack); err != nil { |
| 449 | return err |
| 450 | } |
| 451 | |
| 452 | if m.Rack != nil { |
| 453 | |
| 454 | if err := m.Rack.Validate(formats); err != nil { |
| 455 | if ve, ok := err.(*errors.Validation); ok { |
| 456 | return ve.ValidateName("rack") |
| 457 | } |
| 458 | return err |
| 459 | } |
| 460 | } |
| 461 | |
| 462 | return nil |
| 463 | } |
| 464 | |
| 465 | func (m *Device) validateSerial(formats strfmt.Registry) error { |
| 466 | |
| 467 | if swag.IsZero(m.Serial) { // not required |
| 468 | return nil |
| 469 | } |
| 470 | |
| 471 | if err := validate.MaxLength("serial", "body", string(m.Serial), 50); err != nil { |
| 472 | return err |
| 473 | } |
| 474 | |
| 475 | return nil |
| 476 | } |
| 477 | |
| 478 | func (m *Device) validateSite(formats strfmt.Registry) error { |
| 479 | |
| 480 | if err := validate.Required("site", "body", m.Site); err != nil { |
| 481 | return err |
| 482 | } |
| 483 | |
| 484 | if m.Site != nil { |
| 485 | |
| 486 | if err := m.Site.Validate(formats); err != nil { |
| 487 | if ve, ok := err.(*errors.Validation); ok { |
| 488 | return ve.ValidateName("site") |
| 489 | } |
| 490 | return err |
| 491 | } |
| 492 | } |
| 493 | |
| 494 | return nil |
| 495 | } |
| 496 | |
| 497 | func (m *Device) validateStatus(formats strfmt.Registry) error { |
| 498 | |
| 499 | if err := validate.Required("status", "body", m.Status); err != nil { |
| 500 | return err |
| 501 | } |
| 502 | |
| 503 | if m.Status != nil { |
| 504 | |
| 505 | if err := m.Status.Validate(formats); err != nil { |
| 506 | if ve, ok := err.(*errors.Validation); ok { |
| 507 | return ve.ValidateName("status") |
| 508 | } |
| 509 | return err |
| 510 | } |
| 511 | } |
| 512 | |
| 513 | return nil |
| 514 | } |
| 515 | |
| 516 | func (m *Device) validateTenant(formats strfmt.Registry) error { |
| 517 | |
| 518 | if err := validate.Required("tenant", "body", m.Tenant); err != nil { |
| 519 | return err |
| 520 | } |
| 521 | |
| 522 | if m.Tenant != nil { |
| 523 | |
| 524 | if err := m.Tenant.Validate(formats); err != nil { |
| 525 | if ve, ok := err.(*errors.Validation); ok { |
| 526 | return ve.ValidateName("tenant") |
| 527 | } |
| 528 | return err |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | return nil |
| 533 | } |
| 534 | |
| 535 | func (m *Device) validateVcPosition(formats strfmt.Registry) error { |
| 536 | |
| 537 | if err := validate.Required("vc_position", "body", m.VcPosition); err != nil { |
| 538 | return err |
| 539 | } |
| 540 | |
| 541 | if err := validate.MinimumInt("vc_position", "body", int64(*m.VcPosition), 0, false); err != nil { |
| 542 | return err |
| 543 | } |
| 544 | |
| 545 | if err := validate.MaximumInt("vc_position", "body", int64(*m.VcPosition), 255, false); err != nil { |
| 546 | return err |
| 547 | } |
| 548 | |
| 549 | return nil |
| 550 | } |
| 551 | |
| 552 | func (m *Device) validateVcPriority(formats strfmt.Registry) error { |
| 553 | |
| 554 | if swag.IsZero(m.VcPriority) { // not required |
| 555 | return nil |
| 556 | } |
| 557 | |
| 558 | if err := validate.MinimumInt("vc_priority", "body", int64(*m.VcPriority), 0, false); err != nil { |
| 559 | return err |
| 560 | } |
| 561 | |
| 562 | if err := validate.MaximumInt("vc_priority", "body", int64(*m.VcPriority), 255, false); err != nil { |
| 563 | return err |
| 564 | } |
| 565 | |
| 566 | return nil |
| 567 | } |
| 568 | |
| 569 | func (m *Device) validateVirtualChassis(formats strfmt.Registry) error { |
| 570 | |
| 571 | if err := validate.Required("virtual_chassis", "body", m.VirtualChassis); err != nil { |
| 572 | return err |
| 573 | } |
| 574 | |
| 575 | if m.VirtualChassis != nil { |
| 576 | |
| 577 | if err := m.VirtualChassis.Validate(formats); err != nil { |
| 578 | if ve, ok := err.(*errors.Validation); ok { |
| 579 | return ve.ValidateName("virtual_chassis") |
| 580 | } |
| 581 | return err |
| 582 | } |
| 583 | } |
| 584 | |
| 585 | return nil |
| 586 | } |
| 587 | |
| 588 | // MarshalBinary interface implementation |
| 589 | func (m *Device) MarshalBinary() ([]byte, error) { |
| 590 | if m == nil { |
| 591 | return nil, nil |
| 592 | } |
| 593 | return swag.WriteJSON(m) |
| 594 | } |
| 595 | |
| 596 | // UnmarshalBinary interface implementation |
| 597 | func (m *Device) UnmarshalBinary(b []byte) error { |
| 598 | var res Device |
| 599 | if err := swag.ReadJSON(b, &res); err != nil { |
| 600 | return err |
| 601 | } |
| 602 | *m = res |
| 603 | return nil |
| 604 | } |