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