github.com/digitalocean/go-netbox@v0.0.2/netbox/models/ip_address.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 // IPAddress IP address 35 // 36 // swagger:model IPAddress 37 type IPAddress struct { 38 39 // Address 40 // 41 // IPv4 or IPv6 address (with mask) 42 // Required: true 43 Address *string `json:"address"` 44 45 // Assigned object 46 // Read Only: true 47 AssignedObject map[string]*string `json:"assigned_object,omitempty"` 48 49 // Assigned object id 50 // Maximum: 2.147483647e+09 51 // Minimum: 0 52 AssignedObjectID *int64 `json:"assigned_object_id,omitempty"` 53 54 // Assigned object type 55 AssignedObjectType *string `json:"assigned_object_type,omitempty"` 56 57 // Created 58 // Read Only: true 59 // Format: date 60 Created strfmt.Date `json:"created,omitempty"` 61 62 // Custom fields 63 CustomFields interface{} `json:"custom_fields,omitempty"` 64 65 // Description 66 // Max Length: 200 67 Description string `json:"description,omitempty"` 68 69 // Display 70 // Read Only: true 71 Display string `json:"display,omitempty"` 72 73 // DNS Name 74 // 75 // Hostname or FQDN (not case-sensitive) 76 // Max Length: 255 77 // Pattern: ^[0-9A-Za-z._-]+$ 78 DNSName string `json:"dns_name,omitempty"` 79 80 // family 81 Family *IPAddressFamily `json:"family,omitempty"` 82 83 // Id 84 // Read Only: true 85 ID int64 `json:"id,omitempty"` 86 87 // Last updated 88 // Read Only: true 89 // Format: date-time 90 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"` 91 92 // nat inside 93 NatInside *NestedIPAddress `json:"nat_inside,omitempty"` 94 95 // nat outside 96 NatOutside *NestedIPAddress `json:"nat_outside,omitempty"` 97 98 // role 99 Role *IPAddressRole `json:"role,omitempty"` 100 101 // status 102 Status *IPAddressStatus `json:"status,omitempty"` 103 104 // tags 105 Tags []*NestedTag `json:"tags"` 106 107 // tenant 108 Tenant *NestedTenant `json:"tenant,omitempty"` 109 110 // Url 111 // Read Only: true 112 // Format: uri 113 URL strfmt.URI `json:"url,omitempty"` 114 115 // vrf 116 Vrf *NestedVRF `json:"vrf,omitempty"` 117 } 118 119 // Validate validates this IP address 120 func (m *IPAddress) Validate(formats strfmt.Registry) error { 121 var res []error 122 123 if err := m.validateAddress(formats); err != nil { 124 res = append(res, err) 125 } 126 127 if err := m.validateAssignedObjectID(formats); err != nil { 128 res = append(res, err) 129 } 130 131 if err := m.validateCreated(formats); err != nil { 132 res = append(res, err) 133 } 134 135 if err := m.validateDescription(formats); err != nil { 136 res = append(res, err) 137 } 138 139 if err := m.validateDNSName(formats); err != nil { 140 res = append(res, err) 141 } 142 143 if err := m.validateFamily(formats); err != nil { 144 res = append(res, err) 145 } 146 147 if err := m.validateLastUpdated(formats); err != nil { 148 res = append(res, err) 149 } 150 151 if err := m.validateNatInside(formats); err != nil { 152 res = append(res, err) 153 } 154 155 if err := m.validateNatOutside(formats); err != nil { 156 res = append(res, err) 157 } 158 159 if err := m.validateRole(formats); err != nil { 160 res = append(res, err) 161 } 162 163 if err := m.validateStatus(formats); err != nil { 164 res = append(res, err) 165 } 166 167 if err := m.validateTags(formats); err != nil { 168 res = append(res, err) 169 } 170 171 if err := m.validateTenant(formats); err != nil { 172 res = append(res, err) 173 } 174 175 if err := m.validateURL(formats); err != nil { 176 res = append(res, err) 177 } 178 179 if err := m.validateVrf(formats); err != nil { 180 res = append(res, err) 181 } 182 183 if len(res) > 0 { 184 return errors.CompositeValidationError(res...) 185 } 186 return nil 187 } 188 189 func (m *IPAddress) validateAddress(formats strfmt.Registry) error { 190 191 if err := validate.Required("address", "body", m.Address); err != nil { 192 return err 193 } 194 195 return nil 196 } 197 198 func (m *IPAddress) validateAssignedObjectID(formats strfmt.Registry) error { 199 if swag.IsZero(m.AssignedObjectID) { // not required 200 return nil 201 } 202 203 if err := validate.MinimumInt("assigned_object_id", "body", *m.AssignedObjectID, 0, false); err != nil { 204 return err 205 } 206 207 if err := validate.MaximumInt("assigned_object_id", "body", *m.AssignedObjectID, 2.147483647e+09, false); err != nil { 208 return err 209 } 210 211 return nil 212 } 213 214 func (m *IPAddress) validateCreated(formats strfmt.Registry) error { 215 if swag.IsZero(m.Created) { // not required 216 return nil 217 } 218 219 if err := validate.FormatOf("created", "body", "date", m.Created.String(), formats); err != nil { 220 return err 221 } 222 223 return nil 224 } 225 226 func (m *IPAddress) validateDescription(formats strfmt.Registry) error { 227 if swag.IsZero(m.Description) { // not required 228 return nil 229 } 230 231 if err := validate.MaxLength("description", "body", m.Description, 200); err != nil { 232 return err 233 } 234 235 return nil 236 } 237 238 func (m *IPAddress) validateDNSName(formats strfmt.Registry) error { 239 if swag.IsZero(m.DNSName) { // not required 240 return nil 241 } 242 243 if err := validate.MaxLength("dns_name", "body", m.DNSName, 255); err != nil { 244 return err 245 } 246 247 if err := validate.Pattern("dns_name", "body", m.DNSName, `^[0-9A-Za-z._-]+$`); err != nil { 248 return err 249 } 250 251 return nil 252 } 253 254 func (m *IPAddress) validateFamily(formats strfmt.Registry) error { 255 if swag.IsZero(m.Family) { // not required 256 return nil 257 } 258 259 if m.Family != nil { 260 if err := m.Family.Validate(formats); err != nil { 261 if ve, ok := err.(*errors.Validation); ok { 262 return ve.ValidateName("family") 263 } else if ce, ok := err.(*errors.CompositeError); ok { 264 return ce.ValidateName("family") 265 } 266 return err 267 } 268 } 269 270 return nil 271 } 272 273 func (m *IPAddress) validateLastUpdated(formats strfmt.Registry) error { 274 if swag.IsZero(m.LastUpdated) { // not required 275 return nil 276 } 277 278 if err := validate.FormatOf("last_updated", "body", "date-time", m.LastUpdated.String(), formats); err != nil { 279 return err 280 } 281 282 return nil 283 } 284 285 func (m *IPAddress) validateNatInside(formats strfmt.Registry) error { 286 if swag.IsZero(m.NatInside) { // not required 287 return nil 288 } 289 290 if m.NatInside != nil { 291 if err := m.NatInside.Validate(formats); err != nil { 292 if ve, ok := err.(*errors.Validation); ok { 293 return ve.ValidateName("nat_inside") 294 } else if ce, ok := err.(*errors.CompositeError); ok { 295 return ce.ValidateName("nat_inside") 296 } 297 return err 298 } 299 } 300 301 return nil 302 } 303 304 func (m *IPAddress) validateNatOutside(formats strfmt.Registry) error { 305 if swag.IsZero(m.NatOutside) { // not required 306 return nil 307 } 308 309 if m.NatOutside != nil { 310 if err := m.NatOutside.Validate(formats); err != nil { 311 if ve, ok := err.(*errors.Validation); ok { 312 return ve.ValidateName("nat_outside") 313 } else if ce, ok := err.(*errors.CompositeError); ok { 314 return ce.ValidateName("nat_outside") 315 } 316 return err 317 } 318 } 319 320 return nil 321 } 322 323 func (m *IPAddress) validateRole(formats strfmt.Registry) error { 324 if swag.IsZero(m.Role) { // not required 325 return nil 326 } 327 328 if m.Role != nil { 329 if err := m.Role.Validate(formats); err != nil { 330 if ve, ok := err.(*errors.Validation); ok { 331 return ve.ValidateName("role") 332 } else if ce, ok := err.(*errors.CompositeError); ok { 333 return ce.ValidateName("role") 334 } 335 return err 336 } 337 } 338 339 return nil 340 } 341 342 func (m *IPAddress) validateStatus(formats strfmt.Registry) error { 343 if swag.IsZero(m.Status) { // not required 344 return nil 345 } 346 347 if m.Status != nil { 348 if err := m.Status.Validate(formats); err != nil { 349 if ve, ok := err.(*errors.Validation); ok { 350 return ve.ValidateName("status") 351 } else if ce, ok := err.(*errors.CompositeError); ok { 352 return ce.ValidateName("status") 353 } 354 return err 355 } 356 } 357 358 return nil 359 } 360 361 func (m *IPAddress) validateTags(formats strfmt.Registry) error { 362 if swag.IsZero(m.Tags) { // not required 363 return nil 364 } 365 366 for i := 0; i < len(m.Tags); i++ { 367 if swag.IsZero(m.Tags[i]) { // not required 368 continue 369 } 370 371 if m.Tags[i] != nil { 372 if err := m.Tags[i].Validate(formats); err != nil { 373 if ve, ok := err.(*errors.Validation); ok { 374 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 375 } else if ce, ok := err.(*errors.CompositeError); ok { 376 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 377 } 378 return err 379 } 380 } 381 382 } 383 384 return nil 385 } 386 387 func (m *IPAddress) validateTenant(formats strfmt.Registry) error { 388 if swag.IsZero(m.Tenant) { // not required 389 return nil 390 } 391 392 if m.Tenant != nil { 393 if err := m.Tenant.Validate(formats); err != nil { 394 if ve, ok := err.(*errors.Validation); ok { 395 return ve.ValidateName("tenant") 396 } else if ce, ok := err.(*errors.CompositeError); ok { 397 return ce.ValidateName("tenant") 398 } 399 return err 400 } 401 } 402 403 return nil 404 } 405 406 func (m *IPAddress) validateURL(formats strfmt.Registry) error { 407 if swag.IsZero(m.URL) { // not required 408 return nil 409 } 410 411 if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { 412 return err 413 } 414 415 return nil 416 } 417 418 func (m *IPAddress) validateVrf(formats strfmt.Registry) error { 419 if swag.IsZero(m.Vrf) { // not required 420 return nil 421 } 422 423 if m.Vrf != nil { 424 if err := m.Vrf.Validate(formats); err != nil { 425 if ve, ok := err.(*errors.Validation); ok { 426 return ve.ValidateName("vrf") 427 } else if ce, ok := err.(*errors.CompositeError); ok { 428 return ce.ValidateName("vrf") 429 } 430 return err 431 } 432 } 433 434 return nil 435 } 436 437 // ContextValidate validate this IP address based on the context it is used 438 func (m *IPAddress) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 439 var res []error 440 441 if err := m.contextValidateAssignedObject(ctx, formats); err != nil { 442 res = append(res, err) 443 } 444 445 if err := m.contextValidateCreated(ctx, formats); err != nil { 446 res = append(res, err) 447 } 448 449 if err := m.contextValidateDisplay(ctx, formats); err != nil { 450 res = append(res, err) 451 } 452 453 if err := m.contextValidateFamily(ctx, formats); err != nil { 454 res = append(res, err) 455 } 456 457 if err := m.contextValidateID(ctx, formats); err != nil { 458 res = append(res, err) 459 } 460 461 if err := m.contextValidateLastUpdated(ctx, formats); err != nil { 462 res = append(res, err) 463 } 464 465 if err := m.contextValidateNatInside(ctx, formats); err != nil { 466 res = append(res, err) 467 } 468 469 if err := m.contextValidateNatOutside(ctx, formats); err != nil { 470 res = append(res, err) 471 } 472 473 if err := m.contextValidateRole(ctx, formats); err != nil { 474 res = append(res, err) 475 } 476 477 if err := m.contextValidateStatus(ctx, formats); err != nil { 478 res = append(res, err) 479 } 480 481 if err := m.contextValidateTags(ctx, formats); err != nil { 482 res = append(res, err) 483 } 484 485 if err := m.contextValidateTenant(ctx, formats); err != nil { 486 res = append(res, err) 487 } 488 489 if err := m.contextValidateURL(ctx, formats); err != nil { 490 res = append(res, err) 491 } 492 493 if err := m.contextValidateVrf(ctx, formats); err != nil { 494 res = append(res, err) 495 } 496 497 if len(res) > 0 { 498 return errors.CompositeValidationError(res...) 499 } 500 return nil 501 } 502 503 func (m *IPAddress) contextValidateAssignedObject(ctx context.Context, formats strfmt.Registry) error { 504 505 return nil 506 } 507 508 func (m *IPAddress) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error { 509 510 if err := validate.ReadOnly(ctx, "created", "body", strfmt.Date(m.Created)); err != nil { 511 return err 512 } 513 514 return nil 515 } 516 517 func (m *IPAddress) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error { 518 519 if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil { 520 return err 521 } 522 523 return nil 524 } 525 526 func (m *IPAddress) contextValidateFamily(ctx context.Context, formats strfmt.Registry) error { 527 528 if m.Family != nil { 529 if err := m.Family.ContextValidate(ctx, formats); err != nil { 530 if ve, ok := err.(*errors.Validation); ok { 531 return ve.ValidateName("family") 532 } else if ce, ok := err.(*errors.CompositeError); ok { 533 return ce.ValidateName("family") 534 } 535 return err 536 } 537 } 538 539 return nil 540 } 541 542 func (m *IPAddress) contextValidateID(ctx context.Context, formats strfmt.Registry) error { 543 544 if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil { 545 return err 546 } 547 548 return nil 549 } 550 551 func (m *IPAddress) contextValidateLastUpdated(ctx context.Context, formats strfmt.Registry) error { 552 553 if err := validate.ReadOnly(ctx, "last_updated", "body", strfmt.DateTime(m.LastUpdated)); err != nil { 554 return err 555 } 556 557 return nil 558 } 559 560 func (m *IPAddress) contextValidateNatInside(ctx context.Context, formats strfmt.Registry) error { 561 562 if m.NatInside != nil { 563 if err := m.NatInside.ContextValidate(ctx, formats); err != nil { 564 if ve, ok := err.(*errors.Validation); ok { 565 return ve.ValidateName("nat_inside") 566 } else if ce, ok := err.(*errors.CompositeError); ok { 567 return ce.ValidateName("nat_inside") 568 } 569 return err 570 } 571 } 572 573 return nil 574 } 575 576 func (m *IPAddress) contextValidateNatOutside(ctx context.Context, formats strfmt.Registry) error { 577 578 if m.NatOutside != nil { 579 if err := m.NatOutside.ContextValidate(ctx, formats); err != nil { 580 if ve, ok := err.(*errors.Validation); ok { 581 return ve.ValidateName("nat_outside") 582 } else if ce, ok := err.(*errors.CompositeError); ok { 583 return ce.ValidateName("nat_outside") 584 } 585 return err 586 } 587 } 588 589 return nil 590 } 591 592 func (m *IPAddress) contextValidateRole(ctx context.Context, formats strfmt.Registry) error { 593 594 if m.Role != nil { 595 if err := m.Role.ContextValidate(ctx, formats); err != nil { 596 if ve, ok := err.(*errors.Validation); ok { 597 return ve.ValidateName("role") 598 } else if ce, ok := err.(*errors.CompositeError); ok { 599 return ce.ValidateName("role") 600 } 601 return err 602 } 603 } 604 605 return nil 606 } 607 608 func (m *IPAddress) contextValidateStatus(ctx context.Context, formats strfmt.Registry) error { 609 610 if m.Status != nil { 611 if err := m.Status.ContextValidate(ctx, formats); err != nil { 612 if ve, ok := err.(*errors.Validation); ok { 613 return ve.ValidateName("status") 614 } else if ce, ok := err.(*errors.CompositeError); ok { 615 return ce.ValidateName("status") 616 } 617 return err 618 } 619 } 620 621 return nil 622 } 623 624 func (m *IPAddress) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { 625 626 for i := 0; i < len(m.Tags); i++ { 627 628 if m.Tags[i] != nil { 629 if err := m.Tags[i].ContextValidate(ctx, formats); err != nil { 630 if ve, ok := err.(*errors.Validation); ok { 631 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 632 } else if ce, ok := err.(*errors.CompositeError); ok { 633 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 634 } 635 return err 636 } 637 } 638 639 } 640 641 return nil 642 } 643 644 func (m *IPAddress) contextValidateTenant(ctx context.Context, formats strfmt.Registry) error { 645 646 if m.Tenant != nil { 647 if err := m.Tenant.ContextValidate(ctx, formats); err != nil { 648 if ve, ok := err.(*errors.Validation); ok { 649 return ve.ValidateName("tenant") 650 } else if ce, ok := err.(*errors.CompositeError); ok { 651 return ce.ValidateName("tenant") 652 } 653 return err 654 } 655 } 656 657 return nil 658 } 659 660 func (m *IPAddress) contextValidateURL(ctx context.Context, formats strfmt.Registry) error { 661 662 if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil { 663 return err 664 } 665 666 return nil 667 } 668 669 func (m *IPAddress) contextValidateVrf(ctx context.Context, formats strfmt.Registry) error { 670 671 if m.Vrf != nil { 672 if err := m.Vrf.ContextValidate(ctx, formats); err != nil { 673 if ve, ok := err.(*errors.Validation); ok { 674 return ve.ValidateName("vrf") 675 } else if ce, ok := err.(*errors.CompositeError); ok { 676 return ce.ValidateName("vrf") 677 } 678 return err 679 } 680 } 681 682 return nil 683 } 684 685 // MarshalBinary interface implementation 686 func (m *IPAddress) MarshalBinary() ([]byte, error) { 687 if m == nil { 688 return nil, nil 689 } 690 return swag.WriteJSON(m) 691 } 692 693 // UnmarshalBinary interface implementation 694 func (m *IPAddress) UnmarshalBinary(b []byte) error { 695 var res IPAddress 696 if err := swag.ReadJSON(b, &res); err != nil { 697 return err 698 } 699 *m = res 700 return nil 701 } 702 703 // IPAddressFamily Family 704 // 705 // swagger:model IPAddressFamily 706 type IPAddressFamily struct { 707 708 // label 709 // Required: true 710 // Enum: [IPv4 IPv6] 711 Label *string `json:"label"` 712 713 // value 714 // Required: true 715 // Enum: [4 6] 716 Value *int64 `json:"value"` 717 } 718 719 // Validate validates this IP address family 720 func (m *IPAddressFamily) Validate(formats strfmt.Registry) error { 721 var res []error 722 723 if err := m.validateLabel(formats); err != nil { 724 res = append(res, err) 725 } 726 727 if err := m.validateValue(formats); err != nil { 728 res = append(res, err) 729 } 730 731 if len(res) > 0 { 732 return errors.CompositeValidationError(res...) 733 } 734 return nil 735 } 736 737 var ipAddressFamilyTypeLabelPropEnum []interface{} 738 739 func init() { 740 var res []string 741 if err := json.Unmarshal([]byte(`["IPv4","IPv6"]`), &res); err != nil { 742 panic(err) 743 } 744 for _, v := range res { 745 ipAddressFamilyTypeLabelPropEnum = append(ipAddressFamilyTypeLabelPropEnum, v) 746 } 747 } 748 749 const ( 750 751 // IPAddressFamilyLabelIPV4 captures enum value "IPv4" 752 IPAddressFamilyLabelIPV4 string = "IPv4" 753 754 // IPAddressFamilyLabelIPV6 captures enum value "IPv6" 755 IPAddressFamilyLabelIPV6 string = "IPv6" 756 ) 757 758 // prop value enum 759 func (m *IPAddressFamily) validateLabelEnum(path, location string, value string) error { 760 if err := validate.EnumCase(path, location, value, ipAddressFamilyTypeLabelPropEnum, true); err != nil { 761 return err 762 } 763 return nil 764 } 765 766 func (m *IPAddressFamily) validateLabel(formats strfmt.Registry) error { 767 768 if err := validate.Required("family"+"."+"label", "body", m.Label); err != nil { 769 return err 770 } 771 772 // value enum 773 if err := m.validateLabelEnum("family"+"."+"label", "body", *m.Label); err != nil { 774 return err 775 } 776 777 return nil 778 } 779 780 var ipAddressFamilyTypeValuePropEnum []interface{} 781 782 func init() { 783 var res []int64 784 if err := json.Unmarshal([]byte(`[4,6]`), &res); err != nil { 785 panic(err) 786 } 787 for _, v := range res { 788 ipAddressFamilyTypeValuePropEnum = append(ipAddressFamilyTypeValuePropEnum, v) 789 } 790 } 791 792 // prop value enum 793 func (m *IPAddressFamily) validateValueEnum(path, location string, value int64) error { 794 if err := validate.EnumCase(path, location, value, ipAddressFamilyTypeValuePropEnum, true); err != nil { 795 return err 796 } 797 return nil 798 } 799 800 func (m *IPAddressFamily) validateValue(formats strfmt.Registry) error { 801 802 if err := validate.Required("family"+"."+"value", "body", m.Value); err != nil { 803 return err 804 } 805 806 // value enum 807 if err := m.validateValueEnum("family"+"."+"value", "body", *m.Value); err != nil { 808 return err 809 } 810 811 return nil 812 } 813 814 // ContextValidate validate this IP address family based on the context it is used 815 func (m *IPAddressFamily) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 816 var res []error 817 818 if len(res) > 0 { 819 return errors.CompositeValidationError(res...) 820 } 821 return nil 822 } 823 824 // MarshalBinary interface implementation 825 func (m *IPAddressFamily) MarshalBinary() ([]byte, error) { 826 if m == nil { 827 return nil, nil 828 } 829 return swag.WriteJSON(m) 830 } 831 832 // UnmarshalBinary interface implementation 833 func (m *IPAddressFamily) UnmarshalBinary(b []byte) error { 834 var res IPAddressFamily 835 if err := swag.ReadJSON(b, &res); err != nil { 836 return err 837 } 838 *m = res 839 return nil 840 } 841 842 // IPAddressRole Role 843 // 844 // swagger:model IPAddressRole 845 type IPAddressRole struct { 846 847 // label 848 // Required: true 849 // Enum: [Loopback Secondary Anycast VIP VRRP HSRP GLBP CARP] 850 Label *string `json:"label"` 851 852 // value 853 // Required: true 854 // Enum: [loopback secondary anycast vip vrrp hsrp glbp carp] 855 Value *string `json:"value"` 856 } 857 858 // Validate validates this IP address role 859 func (m *IPAddressRole) Validate(formats strfmt.Registry) error { 860 var res []error 861 862 if err := m.validateLabel(formats); err != nil { 863 res = append(res, err) 864 } 865 866 if err := m.validateValue(formats); err != nil { 867 res = append(res, err) 868 } 869 870 if len(res) > 0 { 871 return errors.CompositeValidationError(res...) 872 } 873 return nil 874 } 875 876 var ipAddressRoleTypeLabelPropEnum []interface{} 877 878 func init() { 879 var res []string 880 if err := json.Unmarshal([]byte(`["Loopback","Secondary","Anycast","VIP","VRRP","HSRP","GLBP","CARP"]`), &res); err != nil { 881 panic(err) 882 } 883 for _, v := range res { 884 ipAddressRoleTypeLabelPropEnum = append(ipAddressRoleTypeLabelPropEnum, v) 885 } 886 } 887 888 const ( 889 890 // IPAddressRoleLabelLoopback captures enum value "Loopback" 891 IPAddressRoleLabelLoopback string = "Loopback" 892 893 // IPAddressRoleLabelSecondary captures enum value "Secondary" 894 IPAddressRoleLabelSecondary string = "Secondary" 895 896 // IPAddressRoleLabelAnycast captures enum value "Anycast" 897 IPAddressRoleLabelAnycast string = "Anycast" 898 899 // IPAddressRoleLabelVIP captures enum value "VIP" 900 IPAddressRoleLabelVIP string = "VIP" 901 902 // IPAddressRoleLabelVRRP captures enum value "VRRP" 903 IPAddressRoleLabelVRRP string = "VRRP" 904 905 // IPAddressRoleLabelHSRP captures enum value "HSRP" 906 IPAddressRoleLabelHSRP string = "HSRP" 907 908 // IPAddressRoleLabelGLBP captures enum value "GLBP" 909 IPAddressRoleLabelGLBP string = "GLBP" 910 911 // IPAddressRoleLabelCARP captures enum value "CARP" 912 IPAddressRoleLabelCARP string = "CARP" 913 ) 914 915 // prop value enum 916 func (m *IPAddressRole) validateLabelEnum(path, location string, value string) error { 917 if err := validate.EnumCase(path, location, value, ipAddressRoleTypeLabelPropEnum, true); err != nil { 918 return err 919 } 920 return nil 921 } 922 923 func (m *IPAddressRole) validateLabel(formats strfmt.Registry) error { 924 925 if err := validate.Required("role"+"."+"label", "body", m.Label); err != nil { 926 return err 927 } 928 929 // value enum 930 if err := m.validateLabelEnum("role"+"."+"label", "body", *m.Label); err != nil { 931 return err 932 } 933 934 return nil 935 } 936 937 var ipAddressRoleTypeValuePropEnum []interface{} 938 939 func init() { 940 var res []string 941 if err := json.Unmarshal([]byte(`["loopback","secondary","anycast","vip","vrrp","hsrp","glbp","carp"]`), &res); err != nil { 942 panic(err) 943 } 944 for _, v := range res { 945 ipAddressRoleTypeValuePropEnum = append(ipAddressRoleTypeValuePropEnum, v) 946 } 947 } 948 949 const ( 950 951 // IPAddressRoleValueLoopback captures enum value "loopback" 952 IPAddressRoleValueLoopback string = "loopback" 953 954 // IPAddressRoleValueSecondary captures enum value "secondary" 955 IPAddressRoleValueSecondary string = "secondary" 956 957 // IPAddressRoleValueAnycast captures enum value "anycast" 958 IPAddressRoleValueAnycast string = "anycast" 959 960 // IPAddressRoleValueVip captures enum value "vip" 961 IPAddressRoleValueVip string = "vip" 962 963 // IPAddressRoleValueVrrp captures enum value "vrrp" 964 IPAddressRoleValueVrrp string = "vrrp" 965 966 // IPAddressRoleValueHsrp captures enum value "hsrp" 967 IPAddressRoleValueHsrp string = "hsrp" 968 969 // IPAddressRoleValueGlbp captures enum value "glbp" 970 IPAddressRoleValueGlbp string = "glbp" 971 972 // IPAddressRoleValueCarp captures enum value "carp" 973 IPAddressRoleValueCarp string = "carp" 974 ) 975 976 // prop value enum 977 func (m *IPAddressRole) validateValueEnum(path, location string, value string) error { 978 if err := validate.EnumCase(path, location, value, ipAddressRoleTypeValuePropEnum, true); err != nil { 979 return err 980 } 981 return nil 982 } 983 984 func (m *IPAddressRole) validateValue(formats strfmt.Registry) error { 985 986 if err := validate.Required("role"+"."+"value", "body", m.Value); err != nil { 987 return err 988 } 989 990 // value enum 991 if err := m.validateValueEnum("role"+"."+"value", "body", *m.Value); err != nil { 992 return err 993 } 994 995 return nil 996 } 997 998 // ContextValidate validates this IP address role based on context it is used 999 func (m *IPAddressRole) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 1000 return nil 1001 } 1002 1003 // MarshalBinary interface implementation 1004 func (m *IPAddressRole) MarshalBinary() ([]byte, error) { 1005 if m == nil { 1006 return nil, nil 1007 } 1008 return swag.WriteJSON(m) 1009 } 1010 1011 // UnmarshalBinary interface implementation 1012 func (m *IPAddressRole) UnmarshalBinary(b []byte) error { 1013 var res IPAddressRole 1014 if err := swag.ReadJSON(b, &res); err != nil { 1015 return err 1016 } 1017 *m = res 1018 return nil 1019 } 1020 1021 // IPAddressStatus Status 1022 // 1023 // swagger:model IPAddressStatus 1024 type IPAddressStatus struct { 1025 1026 // label 1027 // Required: true 1028 // Enum: [Active Reserved Deprecated DHCP SLAAC] 1029 Label *string `json:"label"` 1030 1031 // value 1032 // Required: true 1033 // Enum: [active reserved deprecated dhcp slaac] 1034 Value *string `json:"value"` 1035 } 1036 1037 // Validate validates this IP address status 1038 func (m *IPAddressStatus) Validate(formats strfmt.Registry) error { 1039 var res []error 1040 1041 if err := m.validateLabel(formats); err != nil { 1042 res = append(res, err) 1043 } 1044 1045 if err := m.validateValue(formats); err != nil { 1046 res = append(res, err) 1047 } 1048 1049 if len(res) > 0 { 1050 return errors.CompositeValidationError(res...) 1051 } 1052 return nil 1053 } 1054 1055 var ipAddressStatusTypeLabelPropEnum []interface{} 1056 1057 func init() { 1058 var res []string 1059 if err := json.Unmarshal([]byte(`["Active","Reserved","Deprecated","DHCP","SLAAC"]`), &res); err != nil { 1060 panic(err) 1061 } 1062 for _, v := range res { 1063 ipAddressStatusTypeLabelPropEnum = append(ipAddressStatusTypeLabelPropEnum, v) 1064 } 1065 } 1066 1067 const ( 1068 1069 // IPAddressStatusLabelActive captures enum value "Active" 1070 IPAddressStatusLabelActive string = "Active" 1071 1072 // IPAddressStatusLabelReserved captures enum value "Reserved" 1073 IPAddressStatusLabelReserved string = "Reserved" 1074 1075 // IPAddressStatusLabelDeprecated captures enum value "Deprecated" 1076 IPAddressStatusLabelDeprecated string = "Deprecated" 1077 1078 // IPAddressStatusLabelDHCP captures enum value "DHCP" 1079 IPAddressStatusLabelDHCP string = "DHCP" 1080 1081 // IPAddressStatusLabelSLAAC captures enum value "SLAAC" 1082 IPAddressStatusLabelSLAAC string = "SLAAC" 1083 ) 1084 1085 // prop value enum 1086 func (m *IPAddressStatus) validateLabelEnum(path, location string, value string) error { 1087 if err := validate.EnumCase(path, location, value, ipAddressStatusTypeLabelPropEnum, true); err != nil { 1088 return err 1089 } 1090 return nil 1091 } 1092 1093 func (m *IPAddressStatus) validateLabel(formats strfmt.Registry) error { 1094 1095 if err := validate.Required("status"+"."+"label", "body", m.Label); err != nil { 1096 return err 1097 } 1098 1099 // value enum 1100 if err := m.validateLabelEnum("status"+"."+"label", "body", *m.Label); err != nil { 1101 return err 1102 } 1103 1104 return nil 1105 } 1106 1107 var ipAddressStatusTypeValuePropEnum []interface{} 1108 1109 func init() { 1110 var res []string 1111 if err := json.Unmarshal([]byte(`["active","reserved","deprecated","dhcp","slaac"]`), &res); err != nil { 1112 panic(err) 1113 } 1114 for _, v := range res { 1115 ipAddressStatusTypeValuePropEnum = append(ipAddressStatusTypeValuePropEnum, v) 1116 } 1117 } 1118 1119 const ( 1120 1121 // IPAddressStatusValueActive captures enum value "active" 1122 IPAddressStatusValueActive string = "active" 1123 1124 // IPAddressStatusValueReserved captures enum value "reserved" 1125 IPAddressStatusValueReserved string = "reserved" 1126 1127 // IPAddressStatusValueDeprecated captures enum value "deprecated" 1128 IPAddressStatusValueDeprecated string = "deprecated" 1129 1130 // IPAddressStatusValueDhcp captures enum value "dhcp" 1131 IPAddressStatusValueDhcp string = "dhcp" 1132 1133 // IPAddressStatusValueSlaac captures enum value "slaac" 1134 IPAddressStatusValueSlaac string = "slaac" 1135 ) 1136 1137 // prop value enum 1138 func (m *IPAddressStatus) validateValueEnum(path, location string, value string) error { 1139 if err := validate.EnumCase(path, location, value, ipAddressStatusTypeValuePropEnum, true); err != nil { 1140 return err 1141 } 1142 return nil 1143 } 1144 1145 func (m *IPAddressStatus) validateValue(formats strfmt.Registry) error { 1146 1147 if err := validate.Required("status"+"."+"value", "body", m.Value); err != nil { 1148 return err 1149 } 1150 1151 // value enum 1152 if err := m.validateValueEnum("status"+"."+"value", "body", *m.Value); err != nil { 1153 return err 1154 } 1155 1156 return nil 1157 } 1158 1159 // ContextValidate validates this IP address status based on context it is used 1160 func (m *IPAddressStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 1161 return nil 1162 } 1163 1164 // MarshalBinary interface implementation 1165 func (m *IPAddressStatus) MarshalBinary() ([]byte, error) { 1166 if m == nil { 1167 return nil, nil 1168 } 1169 return swag.WriteJSON(m) 1170 } 1171 1172 // UnmarshalBinary interface implementation 1173 func (m *IPAddressStatus) UnmarshalBinary(b []byte) error { 1174 var res IPAddressStatus 1175 if err := swag.ReadJSON(b, &res); err != nil { 1176 return err 1177 } 1178 *m = res 1179 return nil 1180 }