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