github.com/digitalocean/go-netbox@v0.0.2/netbox/models/device.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 // Copyright 2020 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 18 package models 19 20 // This file was generated by the swagger tool. 21 // Editing this file might prove futile when you re-run the swagger generate command 22 23 import ( 24 "context" 25 "encoding/json" 26 "strconv" 27 28 "github.com/go-openapi/errors" 29 "github.com/go-openapi/strfmt" 30 "github.com/go-openapi/swag" 31 "github.com/go-openapi/validate" 32 ) 33 34 // Device device 35 // 36 // swagger:model Device 37 type Device struct { 38 39 // Asset tag 40 // 41 // A unique tag used to identify this device 42 // Max Length: 50 43 AssetTag *string `json:"asset_tag,omitempty"` 44 45 // cluster 46 Cluster *NestedCluster `json:"cluster,omitempty"` 47 48 // Comments 49 Comments string `json:"comments,omitempty"` 50 51 // Created 52 // Read Only: true 53 // Format: date 54 Created strfmt.Date `json:"created,omitempty"` 55 56 // Custom fields 57 CustomFields interface{} `json:"custom_fields,omitempty"` 58 59 // device role 60 // Required: true 61 DeviceRole *NestedDeviceRole `json:"device_role"` 62 63 // device type 64 // Required: true 65 DeviceType *NestedDeviceType `json:"device_type"` 66 67 // Display 68 // Read Only: true 69 Display string `json:"display,omitempty"` 70 71 // Display name 72 // Read Only: true 73 DisplayName string `json:"display_name,omitempty"` 74 75 // face 76 Face *DeviceFace `json:"face,omitempty"` 77 78 // Id 79 // Read Only: true 80 ID int64 `json:"id,omitempty"` 81 82 // Last updated 83 // Read Only: true 84 // Format: date-time 85 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"` 86 87 // Local context data 88 LocalContextData *string `json:"local_context_data,omitempty"` 89 90 // location 91 Location *NestedLocation `json:"location,omitempty"` 92 93 // Name 94 // Max Length: 64 95 Name *string `json:"name,omitempty"` 96 97 // parent device 98 ParentDevice *NestedDevice `json:"parent_device,omitempty"` 99 100 // platform 101 Platform *NestedPlatform `json:"platform,omitempty"` 102 103 // Position (U) 104 // 105 // The lowest-numbered unit occupied by the device 106 // Maximum: 32767 107 // Minimum: 1 108 Position *int64 `json:"position,omitempty"` 109 110 // primary ip 111 PrimaryIP *NestedIPAddress `json:"primary_ip,omitempty"` 112 113 // primary ip4 114 PrimaryIp4 *NestedIPAddress `json:"primary_ip4,omitempty"` 115 116 // primary ip6 117 PrimaryIp6 *NestedIPAddress `json:"primary_ip6,omitempty"` 118 119 // rack 120 Rack *NestedRack `json:"rack,omitempty"` 121 122 // Serial number 123 // Max Length: 50 124 Serial string `json:"serial,omitempty"` 125 126 // site 127 // Required: true 128 Site *NestedSite `json:"site"` 129 130 // status 131 Status *DeviceStatus `json:"status,omitempty"` 132 133 // tags 134 Tags []*NestedTag `json:"tags"` 135 136 // tenant 137 Tenant *NestedTenant `json:"tenant,omitempty"` 138 139 // Url 140 // Read Only: true 141 // Format: uri 142 URL strfmt.URI `json:"url,omitempty"` 143 144 // Vc position 145 // Maximum: 255 146 // Minimum: 0 147 VcPosition *int64 `json:"vc_position,omitempty"` 148 149 // Vc priority 150 // Maximum: 255 151 // Minimum: 0 152 VcPriority *int64 `json:"vc_priority,omitempty"` 153 154 // virtual chassis 155 VirtualChassis *NestedVirtualChassis `json:"virtual_chassis,omitempty"` 156 } 157 158 // Validate validates this device 159 func (m *Device) Validate(formats strfmt.Registry) error { 160 var res []error 161 162 if err := m.validateAssetTag(formats); err != nil { 163 res = append(res, err) 164 } 165 166 if err := m.validateCluster(formats); err != nil { 167 res = append(res, err) 168 } 169 170 if err := m.validateCreated(formats); err != nil { 171 res = append(res, err) 172 } 173 174 if err := m.validateDeviceRole(formats); err != nil { 175 res = append(res, err) 176 } 177 178 if err := m.validateDeviceType(formats); err != nil { 179 res = append(res, err) 180 } 181 182 if err := m.validateFace(formats); err != nil { 183 res = append(res, err) 184 } 185 186 if err := m.validateLastUpdated(formats); err != nil { 187 res = append(res, err) 188 } 189 190 if err := m.validateLocation(formats); err != nil { 191 res = append(res, err) 192 } 193 194 if err := m.validateName(formats); err != nil { 195 res = append(res, err) 196 } 197 198 if err := m.validateParentDevice(formats); err != nil { 199 res = append(res, err) 200 } 201 202 if err := m.validatePlatform(formats); err != nil { 203 res = append(res, err) 204 } 205 206 if err := m.validatePosition(formats); err != nil { 207 res = append(res, err) 208 } 209 210 if err := m.validatePrimaryIP(formats); err != nil { 211 res = append(res, err) 212 } 213 214 if err := m.validatePrimaryIp4(formats); err != nil { 215 res = append(res, err) 216 } 217 218 if err := m.validatePrimaryIp6(formats); err != nil { 219 res = append(res, err) 220 } 221 222 if err := m.validateRack(formats); err != nil { 223 res = append(res, err) 224 } 225 226 if err := m.validateSerial(formats); err != nil { 227 res = append(res, err) 228 } 229 230 if err := m.validateSite(formats); err != nil { 231 res = append(res, err) 232 } 233 234 if err := m.validateStatus(formats); err != nil { 235 res = append(res, err) 236 } 237 238 if err := m.validateTags(formats); err != nil { 239 res = append(res, err) 240 } 241 242 if err := m.validateTenant(formats); err != nil { 243 res = append(res, err) 244 } 245 246 if err := m.validateURL(formats); err != nil { 247 res = append(res, err) 248 } 249 250 if err := m.validateVcPosition(formats); err != nil { 251 res = append(res, err) 252 } 253 254 if err := m.validateVcPriority(formats); err != nil { 255 res = append(res, err) 256 } 257 258 if err := m.validateVirtualChassis(formats); err != nil { 259 res = append(res, err) 260 } 261 262 if len(res) > 0 { 263 return errors.CompositeValidationError(res...) 264 } 265 return nil 266 } 267 268 func (m *Device) validateAssetTag(formats strfmt.Registry) error { 269 if swag.IsZero(m.AssetTag) { // not required 270 return nil 271 } 272 273 if err := validate.MaxLength("asset_tag", "body", *m.AssetTag, 50); err != nil { 274 return err 275 } 276 277 return nil 278 } 279 280 func (m *Device) validateCluster(formats strfmt.Registry) error { 281 if swag.IsZero(m.Cluster) { // not required 282 return nil 283 } 284 285 if m.Cluster != nil { 286 if err := m.Cluster.Validate(formats); err != nil { 287 if ve, ok := err.(*errors.Validation); ok { 288 return ve.ValidateName("cluster") 289 } else if ce, ok := err.(*errors.CompositeError); ok { 290 return ce.ValidateName("cluster") 291 } 292 return err 293 } 294 } 295 296 return nil 297 } 298 299 func (m *Device) validateCreated(formats strfmt.Registry) error { 300 if swag.IsZero(m.Created) { // not required 301 return nil 302 } 303 304 if err := validate.FormatOf("created", "body", "date", m.Created.String(), formats); err != nil { 305 return err 306 } 307 308 return nil 309 } 310 311 func (m *Device) validateDeviceRole(formats strfmt.Registry) error { 312 313 if err := validate.Required("device_role", "body", m.DeviceRole); err != nil { 314 return err 315 } 316 317 if m.DeviceRole != nil { 318 if err := m.DeviceRole.Validate(formats); err != nil { 319 if ve, ok := err.(*errors.Validation); ok { 320 return ve.ValidateName("device_role") 321 } else if ce, ok := err.(*errors.CompositeError); ok { 322 return ce.ValidateName("device_role") 323 } 324 return err 325 } 326 } 327 328 return nil 329 } 330 331 func (m *Device) validateDeviceType(formats strfmt.Registry) error { 332 333 if err := validate.Required("device_type", "body", m.DeviceType); err != nil { 334 return err 335 } 336 337 if m.DeviceType != nil { 338 if err := m.DeviceType.Validate(formats); err != nil { 339 if ve, ok := err.(*errors.Validation); ok { 340 return ve.ValidateName("device_type") 341 } else if ce, ok := err.(*errors.CompositeError); ok { 342 return ce.ValidateName("device_type") 343 } 344 return err 345 } 346 } 347 348 return nil 349 } 350 351 func (m *Device) validateFace(formats strfmt.Registry) error { 352 if swag.IsZero(m.Face) { // not required 353 return nil 354 } 355 356 if m.Face != nil { 357 if err := m.Face.Validate(formats); err != nil { 358 if ve, ok := err.(*errors.Validation); ok { 359 return ve.ValidateName("face") 360 } else if ce, ok := err.(*errors.CompositeError); ok { 361 return ce.ValidateName("face") 362 } 363 return err 364 } 365 } 366 367 return nil 368 } 369 370 func (m *Device) validateLastUpdated(formats strfmt.Registry) error { 371 if swag.IsZero(m.LastUpdated) { // not required 372 return nil 373 } 374 375 if err := validate.FormatOf("last_updated", "body", "date-time", m.LastUpdated.String(), formats); err != nil { 376 return err 377 } 378 379 return nil 380 } 381 382 func (m *Device) validateLocation(formats strfmt.Registry) error { 383 if swag.IsZero(m.Location) { // not required 384 return nil 385 } 386 387 if m.Location != nil { 388 if err := m.Location.Validate(formats); err != nil { 389 if ve, ok := err.(*errors.Validation); ok { 390 return ve.ValidateName("location") 391 } else if ce, ok := err.(*errors.CompositeError); ok { 392 return ce.ValidateName("location") 393 } 394 return err 395 } 396 } 397 398 return nil 399 } 400 401 func (m *Device) validateName(formats strfmt.Registry) error { 402 if swag.IsZero(m.Name) { // not required 403 return nil 404 } 405 406 if err := validate.MaxLength("name", "body", *m.Name, 64); err != nil { 407 return err 408 } 409 410 return nil 411 } 412 413 func (m *Device) validateParentDevice(formats strfmt.Registry) error { 414 if swag.IsZero(m.ParentDevice) { // not required 415 return nil 416 } 417 418 if m.ParentDevice != nil { 419 if err := m.ParentDevice.Validate(formats); err != nil { 420 if ve, ok := err.(*errors.Validation); ok { 421 return ve.ValidateName("parent_device") 422 } else if ce, ok := err.(*errors.CompositeError); ok { 423 return ce.ValidateName("parent_device") 424 } 425 return err 426 } 427 } 428 429 return nil 430 } 431 432 func (m *Device) validatePlatform(formats strfmt.Registry) error { 433 if swag.IsZero(m.Platform) { // not required 434 return nil 435 } 436 437 if m.Platform != nil { 438 if err := m.Platform.Validate(formats); err != nil { 439 if ve, ok := err.(*errors.Validation); ok { 440 return ve.ValidateName("platform") 441 } else if ce, ok := err.(*errors.CompositeError); ok { 442 return ce.ValidateName("platform") 443 } 444 return err 445 } 446 } 447 448 return nil 449 } 450 451 func (m *Device) validatePosition(formats strfmt.Registry) error { 452 if swag.IsZero(m.Position) { // not required 453 return nil 454 } 455 456 if err := validate.MinimumInt("position", "body", *m.Position, 1, false); err != nil { 457 return err 458 } 459 460 if err := validate.MaximumInt("position", "body", *m.Position, 32767, false); err != nil { 461 return err 462 } 463 464 return nil 465 } 466 467 func (m *Device) validatePrimaryIP(formats strfmt.Registry) error { 468 if swag.IsZero(m.PrimaryIP) { // not required 469 return nil 470 } 471 472 if m.PrimaryIP != nil { 473 if err := m.PrimaryIP.Validate(formats); err != nil { 474 if ve, ok := err.(*errors.Validation); ok { 475 return ve.ValidateName("primary_ip") 476 } else if ce, ok := err.(*errors.CompositeError); ok { 477 return ce.ValidateName("primary_ip") 478 } 479 return err 480 } 481 } 482 483 return nil 484 } 485 486 func (m *Device) validatePrimaryIp4(formats strfmt.Registry) error { 487 if swag.IsZero(m.PrimaryIp4) { // not required 488 return nil 489 } 490 491 if m.PrimaryIp4 != nil { 492 if err := m.PrimaryIp4.Validate(formats); err != nil { 493 if ve, ok := err.(*errors.Validation); ok { 494 return ve.ValidateName("primary_ip4") 495 } else if ce, ok := err.(*errors.CompositeError); ok { 496 return ce.ValidateName("primary_ip4") 497 } 498 return err 499 } 500 } 501 502 return nil 503 } 504 505 func (m *Device) validatePrimaryIp6(formats strfmt.Registry) error { 506 if swag.IsZero(m.PrimaryIp6) { // not required 507 return nil 508 } 509 510 if m.PrimaryIp6 != nil { 511 if err := m.PrimaryIp6.Validate(formats); err != nil { 512 if ve, ok := err.(*errors.Validation); ok { 513 return ve.ValidateName("primary_ip6") 514 } else if ce, ok := err.(*errors.CompositeError); ok { 515 return ce.ValidateName("primary_ip6") 516 } 517 return err 518 } 519 } 520 521 return nil 522 } 523 524 func (m *Device) validateRack(formats strfmt.Registry) error { 525 if swag.IsZero(m.Rack) { // not required 526 return nil 527 } 528 529 if m.Rack != nil { 530 if err := m.Rack.Validate(formats); err != nil { 531 if ve, ok := err.(*errors.Validation); ok { 532 return ve.ValidateName("rack") 533 } else if ce, ok := err.(*errors.CompositeError); ok { 534 return ce.ValidateName("rack") 535 } 536 return err 537 } 538 } 539 540 return nil 541 } 542 543 func (m *Device) validateSerial(formats strfmt.Registry) error { 544 if swag.IsZero(m.Serial) { // not required 545 return nil 546 } 547 548 if err := validate.MaxLength("serial", "body", m.Serial, 50); err != nil { 549 return err 550 } 551 552 return nil 553 } 554 555 func (m *Device) validateSite(formats strfmt.Registry) error { 556 557 if err := validate.Required("site", "body", m.Site); err != nil { 558 return err 559 } 560 561 if m.Site != nil { 562 if err := m.Site.Validate(formats); err != nil { 563 if ve, ok := err.(*errors.Validation); ok { 564 return ve.ValidateName("site") 565 } else if ce, ok := err.(*errors.CompositeError); ok { 566 return ce.ValidateName("site") 567 } 568 return err 569 } 570 } 571 572 return nil 573 } 574 575 func (m *Device) validateStatus(formats strfmt.Registry) error { 576 if swag.IsZero(m.Status) { // not required 577 return nil 578 } 579 580 if m.Status != nil { 581 if err := m.Status.Validate(formats); err != nil { 582 if ve, ok := err.(*errors.Validation); ok { 583 return ve.ValidateName("status") 584 } else if ce, ok := err.(*errors.CompositeError); ok { 585 return ce.ValidateName("status") 586 } 587 return err 588 } 589 } 590 591 return nil 592 } 593 594 func (m *Device) validateTags(formats strfmt.Registry) error { 595 if swag.IsZero(m.Tags) { // not required 596 return nil 597 } 598 599 for i := 0; i < len(m.Tags); i++ { 600 if swag.IsZero(m.Tags[i]) { // not required 601 continue 602 } 603 604 if m.Tags[i] != nil { 605 if err := m.Tags[i].Validate(formats); err != nil { 606 if ve, ok := err.(*errors.Validation); ok { 607 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 608 } else if ce, ok := err.(*errors.CompositeError); ok { 609 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 610 } 611 return err 612 } 613 } 614 615 } 616 617 return nil 618 } 619 620 func (m *Device) validateTenant(formats strfmt.Registry) error { 621 if swag.IsZero(m.Tenant) { // not required 622 return nil 623 } 624 625 if m.Tenant != nil { 626 if err := m.Tenant.Validate(formats); err != nil { 627 if ve, ok := err.(*errors.Validation); ok { 628 return ve.ValidateName("tenant") 629 } else if ce, ok := err.(*errors.CompositeError); ok { 630 return ce.ValidateName("tenant") 631 } 632 return err 633 } 634 } 635 636 return nil 637 } 638 639 func (m *Device) validateURL(formats strfmt.Registry) error { 640 if swag.IsZero(m.URL) { // not required 641 return nil 642 } 643 644 if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { 645 return err 646 } 647 648 return nil 649 } 650 651 func (m *Device) validateVcPosition(formats strfmt.Registry) error { 652 if swag.IsZero(m.VcPosition) { // not required 653 return nil 654 } 655 656 if err := validate.MinimumInt("vc_position", "body", *m.VcPosition, 0, false); err != nil { 657 return err 658 } 659 660 if err := validate.MaximumInt("vc_position", "body", *m.VcPosition, 255, false); err != nil { 661 return err 662 } 663 664 return nil 665 } 666 667 func (m *Device) validateVcPriority(formats strfmt.Registry) error { 668 if swag.IsZero(m.VcPriority) { // not required 669 return nil 670 } 671 672 if err := validate.MinimumInt("vc_priority", "body", *m.VcPriority, 0, false); err != nil { 673 return err 674 } 675 676 if err := validate.MaximumInt("vc_priority", "body", *m.VcPriority, 255, false); err != nil { 677 return err 678 } 679 680 return nil 681 } 682 683 func (m *Device) validateVirtualChassis(formats strfmt.Registry) error { 684 if swag.IsZero(m.VirtualChassis) { // not required 685 return nil 686 } 687 688 if m.VirtualChassis != nil { 689 if err := m.VirtualChassis.Validate(formats); err != nil { 690 if ve, ok := err.(*errors.Validation); ok { 691 return ve.ValidateName("virtual_chassis") 692 } else if ce, ok := err.(*errors.CompositeError); ok { 693 return ce.ValidateName("virtual_chassis") 694 } 695 return err 696 } 697 } 698 699 return nil 700 } 701 702 // ContextValidate validate this device based on the context it is used 703 func (m *Device) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 704 var res []error 705 706 if err := m.contextValidateCluster(ctx, formats); err != nil { 707 res = append(res, err) 708 } 709 710 if err := m.contextValidateCreated(ctx, formats); err != nil { 711 res = append(res, err) 712 } 713 714 if err := m.contextValidateDeviceRole(ctx, formats); err != nil { 715 res = append(res, err) 716 } 717 718 if err := m.contextValidateDeviceType(ctx, formats); err != nil { 719 res = append(res, err) 720 } 721 722 if err := m.contextValidateDisplay(ctx, formats); err != nil { 723 res = append(res, err) 724 } 725 726 if err := m.contextValidateDisplayName(ctx, formats); err != nil { 727 res = append(res, err) 728 } 729 730 if err := m.contextValidateFace(ctx, formats); err != nil { 731 res = append(res, err) 732 } 733 734 if err := m.contextValidateID(ctx, formats); err != nil { 735 res = append(res, err) 736 } 737 738 if err := m.contextValidateLastUpdated(ctx, formats); err != nil { 739 res = append(res, err) 740 } 741 742 if err := m.contextValidateLocation(ctx, formats); err != nil { 743 res = append(res, err) 744 } 745 746 if err := m.contextValidateParentDevice(ctx, formats); err != nil { 747 res = append(res, err) 748 } 749 750 if err := m.contextValidatePlatform(ctx, formats); err != nil { 751 res = append(res, err) 752 } 753 754 if err := m.contextValidatePrimaryIP(ctx, formats); err != nil { 755 res = append(res, err) 756 } 757 758 if err := m.contextValidatePrimaryIp4(ctx, formats); err != nil { 759 res = append(res, err) 760 } 761 762 if err := m.contextValidatePrimaryIp6(ctx, formats); err != nil { 763 res = append(res, err) 764 } 765 766 if err := m.contextValidateRack(ctx, formats); err != nil { 767 res = append(res, err) 768 } 769 770 if err := m.contextValidateSite(ctx, formats); err != nil { 771 res = append(res, err) 772 } 773 774 if err := m.contextValidateStatus(ctx, formats); err != nil { 775 res = append(res, err) 776 } 777 778 if err := m.contextValidateTags(ctx, formats); err != nil { 779 res = append(res, err) 780 } 781 782 if err := m.contextValidateTenant(ctx, formats); err != nil { 783 res = append(res, err) 784 } 785 786 if err := m.contextValidateURL(ctx, formats); err != nil { 787 res = append(res, err) 788 } 789 790 if err := m.contextValidateVirtualChassis(ctx, formats); err != nil { 791 res = append(res, err) 792 } 793 794 if len(res) > 0 { 795 return errors.CompositeValidationError(res...) 796 } 797 return nil 798 } 799 800 func (m *Device) contextValidateCluster(ctx context.Context, formats strfmt.Registry) error { 801 802 if m.Cluster != nil { 803 if err := m.Cluster.ContextValidate(ctx, formats); err != nil { 804 if ve, ok := err.(*errors.Validation); ok { 805 return ve.ValidateName("cluster") 806 } else if ce, ok := err.(*errors.CompositeError); ok { 807 return ce.ValidateName("cluster") 808 } 809 return err 810 } 811 } 812 813 return nil 814 } 815 816 func (m *Device) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error { 817 818 if err := validate.ReadOnly(ctx, "created", "body", strfmt.Date(m.Created)); err != nil { 819 return err 820 } 821 822 return nil 823 } 824 825 func (m *Device) contextValidateDeviceRole(ctx context.Context, formats strfmt.Registry) error { 826 827 if m.DeviceRole != nil { 828 if err := m.DeviceRole.ContextValidate(ctx, formats); err != nil { 829 if ve, ok := err.(*errors.Validation); ok { 830 return ve.ValidateName("device_role") 831 } else if ce, ok := err.(*errors.CompositeError); ok { 832 return ce.ValidateName("device_role") 833 } 834 return err 835 } 836 } 837 838 return nil 839 } 840 841 func (m *Device) contextValidateDeviceType(ctx context.Context, formats strfmt.Registry) error { 842 843 if m.DeviceType != nil { 844 if err := m.DeviceType.ContextValidate(ctx, formats); err != nil { 845 if ve, ok := err.(*errors.Validation); ok { 846 return ve.ValidateName("device_type") 847 } else if ce, ok := err.(*errors.CompositeError); ok { 848 return ce.ValidateName("device_type") 849 } 850 return err 851 } 852 } 853 854 return nil 855 } 856 857 func (m *Device) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error { 858 859 if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil { 860 return err 861 } 862 863 return nil 864 } 865 866 func (m *Device) contextValidateDisplayName(ctx context.Context, formats strfmt.Registry) error { 867 868 if err := validate.ReadOnly(ctx, "display_name", "body", string(m.DisplayName)); err != nil { 869 return err 870 } 871 872 return nil 873 } 874 875 func (m *Device) contextValidateFace(ctx context.Context, formats strfmt.Registry) error { 876 877 if m.Face != nil { 878 if err := m.Face.ContextValidate(ctx, formats); err != nil { 879 if ve, ok := err.(*errors.Validation); ok { 880 return ve.ValidateName("face") 881 } else if ce, ok := err.(*errors.CompositeError); ok { 882 return ce.ValidateName("face") 883 } 884 return err 885 } 886 } 887 888 return nil 889 } 890 891 func (m *Device) contextValidateID(ctx context.Context, formats strfmt.Registry) error { 892 893 if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil { 894 return err 895 } 896 897 return nil 898 } 899 900 func (m *Device) contextValidateLastUpdated(ctx context.Context, formats strfmt.Registry) error { 901 902 if err := validate.ReadOnly(ctx, "last_updated", "body", strfmt.DateTime(m.LastUpdated)); err != nil { 903 return err 904 } 905 906 return nil 907 } 908 909 func (m *Device) contextValidateLocation(ctx context.Context, formats strfmt.Registry) error { 910 911 if m.Location != nil { 912 if err := m.Location.ContextValidate(ctx, formats); err != nil { 913 if ve, ok := err.(*errors.Validation); ok { 914 return ve.ValidateName("location") 915 } else if ce, ok := err.(*errors.CompositeError); ok { 916 return ce.ValidateName("location") 917 } 918 return err 919 } 920 } 921 922 return nil 923 } 924 925 func (m *Device) contextValidateParentDevice(ctx context.Context, formats strfmt.Registry) error { 926 927 if m.ParentDevice != nil { 928 if err := m.ParentDevice.ContextValidate(ctx, formats); err != nil { 929 if ve, ok := err.(*errors.Validation); ok { 930 return ve.ValidateName("parent_device") 931 } else if ce, ok := err.(*errors.CompositeError); ok { 932 return ce.ValidateName("parent_device") 933 } 934 return err 935 } 936 } 937 938 return nil 939 } 940 941 func (m *Device) contextValidatePlatform(ctx context.Context, formats strfmt.Registry) error { 942 943 if m.Platform != nil { 944 if err := m.Platform.ContextValidate(ctx, formats); err != nil { 945 if ve, ok := err.(*errors.Validation); ok { 946 return ve.ValidateName("platform") 947 } else if ce, ok := err.(*errors.CompositeError); ok { 948 return ce.ValidateName("platform") 949 } 950 return err 951 } 952 } 953 954 return nil 955 } 956 957 func (m *Device) contextValidatePrimaryIP(ctx context.Context, formats strfmt.Registry) error { 958 959 if m.PrimaryIP != nil { 960 if err := m.PrimaryIP.ContextValidate(ctx, formats); err != nil { 961 if ve, ok := err.(*errors.Validation); ok { 962 return ve.ValidateName("primary_ip") 963 } else if ce, ok := err.(*errors.CompositeError); ok { 964 return ce.ValidateName("primary_ip") 965 } 966 return err 967 } 968 } 969 970 return nil 971 } 972 973 func (m *Device) contextValidatePrimaryIp4(ctx context.Context, formats strfmt.Registry) error { 974 975 if m.PrimaryIp4 != nil { 976 if err := m.PrimaryIp4.ContextValidate(ctx, formats); err != nil { 977 if ve, ok := err.(*errors.Validation); ok { 978 return ve.ValidateName("primary_ip4") 979 } else if ce, ok := err.(*errors.CompositeError); ok { 980 return ce.ValidateName("primary_ip4") 981 } 982 return err 983 } 984 } 985 986 return nil 987 } 988 989 func (m *Device) contextValidatePrimaryIp6(ctx context.Context, formats strfmt.Registry) error { 990 991 if m.PrimaryIp6 != nil { 992 if err := m.PrimaryIp6.ContextValidate(ctx, formats); err != nil { 993 if ve, ok := err.(*errors.Validation); ok { 994 return ve.ValidateName("primary_ip6") 995 } else if ce, ok := err.(*errors.CompositeError); ok { 996 return ce.ValidateName("primary_ip6") 997 } 998 return err 999 } 1000 } 1001 1002 return nil 1003 } 1004 1005 func (m *Device) contextValidateRack(ctx context.Context, formats strfmt.Registry) error { 1006 1007 if m.Rack != nil { 1008 if err := m.Rack.ContextValidate(ctx, formats); err != nil { 1009 if ve, ok := err.(*errors.Validation); ok { 1010 return ve.ValidateName("rack") 1011 } else if ce, ok := err.(*errors.CompositeError); ok { 1012 return ce.ValidateName("rack") 1013 } 1014 return err 1015 } 1016 } 1017 1018 return nil 1019 } 1020 1021 func (m *Device) contextValidateSite(ctx context.Context, formats strfmt.Registry) error { 1022 1023 if m.Site != nil { 1024 if err := m.Site.ContextValidate(ctx, formats); err != nil { 1025 if ve, ok := err.(*errors.Validation); ok { 1026 return ve.ValidateName("site") 1027 } else if ce, ok := err.(*errors.CompositeError); ok { 1028 return ce.ValidateName("site") 1029 } 1030 return err 1031 } 1032 } 1033 1034 return nil 1035 } 1036 1037 func (m *Device) contextValidateStatus(ctx context.Context, formats strfmt.Registry) error { 1038 1039 if m.Status != nil { 1040 if err := m.Status.ContextValidate(ctx, formats); err != nil { 1041 if ve, ok := err.(*errors.Validation); ok { 1042 return ve.ValidateName("status") 1043 } else if ce, ok := err.(*errors.CompositeError); ok { 1044 return ce.ValidateName("status") 1045 } 1046 return err 1047 } 1048 } 1049 1050 return nil 1051 } 1052 1053 func (m *Device) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { 1054 1055 for i := 0; i < len(m.Tags); i++ { 1056 1057 if m.Tags[i] != nil { 1058 if err := m.Tags[i].ContextValidate(ctx, formats); err != nil { 1059 if ve, ok := err.(*errors.Validation); ok { 1060 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 1061 } else if ce, ok := err.(*errors.CompositeError); ok { 1062 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 1063 } 1064 return err 1065 } 1066 } 1067 1068 } 1069 1070 return nil 1071 } 1072 1073 func (m *Device) contextValidateTenant(ctx context.Context, formats strfmt.Registry) error { 1074 1075 if m.Tenant != nil { 1076 if err := m.Tenant.ContextValidate(ctx, formats); err != nil { 1077 if ve, ok := err.(*errors.Validation); ok { 1078 return ve.ValidateName("tenant") 1079 } else if ce, ok := err.(*errors.CompositeError); ok { 1080 return ce.ValidateName("tenant") 1081 } 1082 return err 1083 } 1084 } 1085 1086 return nil 1087 } 1088 1089 func (m *Device) contextValidateURL(ctx context.Context, formats strfmt.Registry) error { 1090 1091 if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil { 1092 return err 1093 } 1094 1095 return nil 1096 } 1097 1098 func (m *Device) contextValidateVirtualChassis(ctx context.Context, formats strfmt.Registry) error { 1099 1100 if m.VirtualChassis != nil { 1101 if err := m.VirtualChassis.ContextValidate(ctx, formats); err != nil { 1102 if ve, ok := err.(*errors.Validation); ok { 1103 return ve.ValidateName("virtual_chassis") 1104 } else if ce, ok := err.(*errors.CompositeError); ok { 1105 return ce.ValidateName("virtual_chassis") 1106 } 1107 return err 1108 } 1109 } 1110 1111 return nil 1112 } 1113 1114 // MarshalBinary interface implementation 1115 func (m *Device) MarshalBinary() ([]byte, error) { 1116 if m == nil { 1117 return nil, nil 1118 } 1119 return swag.WriteJSON(m) 1120 } 1121 1122 // UnmarshalBinary interface implementation 1123 func (m *Device) UnmarshalBinary(b []byte) error { 1124 var res Device 1125 if err := swag.ReadJSON(b, &res); err != nil { 1126 return err 1127 } 1128 *m = res 1129 return nil 1130 } 1131 1132 // DeviceFace Face 1133 // 1134 // swagger:model DeviceFace 1135 type DeviceFace struct { 1136 1137 // label 1138 // Required: true 1139 // Enum: [Front Rear] 1140 Label *string `json:"label"` 1141 1142 // value 1143 // Required: true 1144 // Enum: [front rear] 1145 Value *string `json:"value"` 1146 } 1147 1148 // Validate validates this device face 1149 func (m *DeviceFace) Validate(formats strfmt.Registry) error { 1150 var res []error 1151 1152 if err := m.validateLabel(formats); err != nil { 1153 res = append(res, err) 1154 } 1155 1156 if err := m.validateValue(formats); err != nil { 1157 res = append(res, err) 1158 } 1159 1160 if len(res) > 0 { 1161 return errors.CompositeValidationError(res...) 1162 } 1163 return nil 1164 } 1165 1166 var deviceFaceTypeLabelPropEnum []interface{} 1167 1168 func init() { 1169 var res []string 1170 if err := json.Unmarshal([]byte(`["Front","Rear"]`), &res); err != nil { 1171 panic(err) 1172 } 1173 for _, v := range res { 1174 deviceFaceTypeLabelPropEnum = append(deviceFaceTypeLabelPropEnum, v) 1175 } 1176 } 1177 1178 const ( 1179 1180 // DeviceFaceLabelFront captures enum value "Front" 1181 DeviceFaceLabelFront string = "Front" 1182 1183 // DeviceFaceLabelRear captures enum value "Rear" 1184 DeviceFaceLabelRear string = "Rear" 1185 ) 1186 1187 // prop value enum 1188 func (m *DeviceFace) validateLabelEnum(path, location string, value string) error { 1189 if err := validate.EnumCase(path, location, value, deviceFaceTypeLabelPropEnum, true); err != nil { 1190 return err 1191 } 1192 return nil 1193 } 1194 1195 func (m *DeviceFace) validateLabel(formats strfmt.Registry) error { 1196 1197 if err := validate.Required("face"+"."+"label", "body", m.Label); err != nil { 1198 return err 1199 } 1200 1201 // value enum 1202 if err := m.validateLabelEnum("face"+"."+"label", "body", *m.Label); err != nil { 1203 return err 1204 } 1205 1206 return nil 1207 } 1208 1209 var deviceFaceTypeValuePropEnum []interface{} 1210 1211 func init() { 1212 var res []string 1213 if err := json.Unmarshal([]byte(`["front","rear"]`), &res); err != nil { 1214 panic(err) 1215 } 1216 for _, v := range res { 1217 deviceFaceTypeValuePropEnum = append(deviceFaceTypeValuePropEnum, v) 1218 } 1219 } 1220 1221 const ( 1222 1223 // DeviceFaceValueFront captures enum value "front" 1224 DeviceFaceValueFront string = "front" 1225 1226 // DeviceFaceValueRear captures enum value "rear" 1227 DeviceFaceValueRear string = "rear" 1228 ) 1229 1230 // prop value enum 1231 func (m *DeviceFace) validateValueEnum(path, location string, value string) error { 1232 if err := validate.EnumCase(path, location, value, deviceFaceTypeValuePropEnum, true); err != nil { 1233 return err 1234 } 1235 return nil 1236 } 1237 1238 func (m *DeviceFace) validateValue(formats strfmt.Registry) error { 1239 1240 if err := validate.Required("face"+"."+"value", "body", m.Value); err != nil { 1241 return err 1242 } 1243 1244 // value enum 1245 if err := m.validateValueEnum("face"+"."+"value", "body", *m.Value); err != nil { 1246 return err 1247 } 1248 1249 return nil 1250 } 1251 1252 // ContextValidate validates this device face based on context it is used 1253 func (m *DeviceFace) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 1254 return nil 1255 } 1256 1257 // MarshalBinary interface implementation 1258 func (m *DeviceFace) MarshalBinary() ([]byte, error) { 1259 if m == nil { 1260 return nil, nil 1261 } 1262 return swag.WriteJSON(m) 1263 } 1264 1265 // UnmarshalBinary interface implementation 1266 func (m *DeviceFace) UnmarshalBinary(b []byte) error { 1267 var res DeviceFace 1268 if err := swag.ReadJSON(b, &res); err != nil { 1269 return err 1270 } 1271 *m = res 1272 return nil 1273 } 1274 1275 // DeviceStatus Status 1276 // 1277 // swagger:model DeviceStatus 1278 type DeviceStatus struct { 1279 1280 // label 1281 // Required: true 1282 // Enum: [Offline Active Planned Staged Failed Inventory Decommissioning] 1283 Label *string `json:"label"` 1284 1285 // value 1286 // Required: true 1287 // Enum: [offline active planned staged failed inventory decommissioning] 1288 Value *string `json:"value"` 1289 } 1290 1291 // Validate validates this device status 1292 func (m *DeviceStatus) Validate(formats strfmt.Registry) error { 1293 var res []error 1294 1295 if err := m.validateLabel(formats); err != nil { 1296 res = append(res, err) 1297 } 1298 1299 if err := m.validateValue(formats); err != nil { 1300 res = append(res, err) 1301 } 1302 1303 if len(res) > 0 { 1304 return errors.CompositeValidationError(res...) 1305 } 1306 return nil 1307 } 1308 1309 var deviceStatusTypeLabelPropEnum []interface{} 1310 1311 func init() { 1312 var res []string 1313 if err := json.Unmarshal([]byte(`["Offline","Active","Planned","Staged","Failed","Inventory","Decommissioning"]`), &res); err != nil { 1314 panic(err) 1315 } 1316 for _, v := range res { 1317 deviceStatusTypeLabelPropEnum = append(deviceStatusTypeLabelPropEnum, v) 1318 } 1319 } 1320 1321 const ( 1322 1323 // DeviceStatusLabelOffline captures enum value "Offline" 1324 DeviceStatusLabelOffline string = "Offline" 1325 1326 // DeviceStatusLabelActive captures enum value "Active" 1327 DeviceStatusLabelActive string = "Active" 1328 1329 // DeviceStatusLabelPlanned captures enum value "Planned" 1330 DeviceStatusLabelPlanned string = "Planned" 1331 1332 // DeviceStatusLabelStaged captures enum value "Staged" 1333 DeviceStatusLabelStaged string = "Staged" 1334 1335 // DeviceStatusLabelFailed captures enum value "Failed" 1336 DeviceStatusLabelFailed string = "Failed" 1337 1338 // DeviceStatusLabelInventory captures enum value "Inventory" 1339 DeviceStatusLabelInventory string = "Inventory" 1340 1341 // DeviceStatusLabelDecommissioning captures enum value "Decommissioning" 1342 DeviceStatusLabelDecommissioning string = "Decommissioning" 1343 ) 1344 1345 // prop value enum 1346 func (m *DeviceStatus) validateLabelEnum(path, location string, value string) error { 1347 if err := validate.EnumCase(path, location, value, deviceStatusTypeLabelPropEnum, true); err != nil { 1348 return err 1349 } 1350 return nil 1351 } 1352 1353 func (m *DeviceStatus) validateLabel(formats strfmt.Registry) error { 1354 1355 if err := validate.Required("status"+"."+"label", "body", m.Label); err != nil { 1356 return err 1357 } 1358 1359 // value enum 1360 if err := m.validateLabelEnum("status"+"."+"label", "body", *m.Label); err != nil { 1361 return err 1362 } 1363 1364 return nil 1365 } 1366 1367 var deviceStatusTypeValuePropEnum []interface{} 1368 1369 func init() { 1370 var res []string 1371 if err := json.Unmarshal([]byte(`["offline","active","planned","staged","failed","inventory","decommissioning"]`), &res); err != nil { 1372 panic(err) 1373 } 1374 for _, v := range res { 1375 deviceStatusTypeValuePropEnum = append(deviceStatusTypeValuePropEnum, v) 1376 } 1377 } 1378 1379 const ( 1380 1381 // DeviceStatusValueOffline captures enum value "offline" 1382 DeviceStatusValueOffline string = "offline" 1383 1384 // DeviceStatusValueActive captures enum value "active" 1385 DeviceStatusValueActive string = "active" 1386 1387 // DeviceStatusValuePlanned captures enum value "planned" 1388 DeviceStatusValuePlanned string = "planned" 1389 1390 // DeviceStatusValueStaged captures enum value "staged" 1391 DeviceStatusValueStaged string = "staged" 1392 1393 // DeviceStatusValueFailed captures enum value "failed" 1394 DeviceStatusValueFailed string = "failed" 1395 1396 // DeviceStatusValueInventory captures enum value "inventory" 1397 DeviceStatusValueInventory string = "inventory" 1398 1399 // DeviceStatusValueDecommissioning captures enum value "decommissioning" 1400 DeviceStatusValueDecommissioning string = "decommissioning" 1401 ) 1402 1403 // prop value enum 1404 func (m *DeviceStatus) validateValueEnum(path, location string, value string) error { 1405 if err := validate.EnumCase(path, location, value, deviceStatusTypeValuePropEnum, true); err != nil { 1406 return err 1407 } 1408 return nil 1409 } 1410 1411 func (m *DeviceStatus) validateValue(formats strfmt.Registry) error { 1412 1413 if err := validate.Required("status"+"."+"value", "body", m.Value); err != nil { 1414 return err 1415 } 1416 1417 // value enum 1418 if err := m.validateValueEnum("status"+"."+"value", "body", *m.Value); err != nil { 1419 return err 1420 } 1421 1422 return nil 1423 } 1424 1425 // ContextValidate validates this device status based on context it is used 1426 func (m *DeviceStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 1427 return nil 1428 } 1429 1430 // MarshalBinary interface implementation 1431 func (m *DeviceStatus) MarshalBinary() ([]byte, error) { 1432 if m == nil { 1433 return nil, nil 1434 } 1435 return swag.WriteJSON(m) 1436 } 1437 1438 // UnmarshalBinary interface implementation 1439 func (m *DeviceStatus) UnmarshalBinary(b []byte) error { 1440 var res DeviceStatus 1441 if err := swag.ReadJSON(b, &res); err != nil { 1442 return err 1443 } 1444 *m = res 1445 return nil 1446 }