github.com/digitalocean/go-netbox@v0.0.2/netbox/models/vm_interface.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 // VMInterface VM interface 35 // 36 // swagger:model VMInterface 37 type VMInterface struct { 38 39 // Count ipaddresses 40 // Read Only: true 41 CountIpaddresses int64 `json:"count_ipaddresses,omitempty"` 42 43 // Created 44 // Read Only: true 45 // Format: date 46 Created strfmt.Date `json:"created,omitempty"` 47 48 // Custom fields 49 CustomFields interface{} `json:"custom_fields,omitempty"` 50 51 // Description 52 // Max Length: 200 53 Description string `json:"description,omitempty"` 54 55 // Display 56 // Read Only: true 57 Display string `json:"display,omitempty"` 58 59 // Enabled 60 Enabled bool `json:"enabled,omitempty"` 61 62 // Id 63 // Read Only: true 64 ID int64 `json:"id,omitempty"` 65 66 // Last updated 67 // Read Only: true 68 // Format: date-time 69 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"` 70 71 // MAC Address 72 MacAddress *string `json:"mac_address,omitempty"` 73 74 // mode 75 Mode *VMInterfaceMode `json:"mode,omitempty"` 76 77 // MTU 78 // Maximum: 65536 79 // Minimum: 1 80 Mtu *int64 `json:"mtu,omitempty"` 81 82 // Name 83 // Required: true 84 // Max Length: 64 85 // Min Length: 1 86 Name *string `json:"name"` 87 88 // parent 89 Parent *NestedVMInterface `json:"parent,omitempty"` 90 91 // tagged vlans 92 // Unique: true 93 TaggedVlans []*NestedVLAN `json:"tagged_vlans"` 94 95 // tags 96 Tags []*NestedTag `json:"tags"` 97 98 // untagged vlan 99 UntaggedVlan *NestedVLAN `json:"untagged_vlan,omitempty"` 100 101 // Url 102 // Read Only: true 103 // Format: uri 104 URL strfmt.URI `json:"url,omitempty"` 105 106 // virtual machine 107 // Required: true 108 VirtualMachine *NestedVirtualMachine `json:"virtual_machine"` 109 } 110 111 // Validate validates this VM interface 112 func (m *VMInterface) Validate(formats strfmt.Registry) error { 113 var res []error 114 115 if err := m.validateCreated(formats); err != nil { 116 res = append(res, err) 117 } 118 119 if err := m.validateDescription(formats); err != nil { 120 res = append(res, err) 121 } 122 123 if err := m.validateLastUpdated(formats); err != nil { 124 res = append(res, err) 125 } 126 127 if err := m.validateMode(formats); err != nil { 128 res = append(res, err) 129 } 130 131 if err := m.validateMtu(formats); err != nil { 132 res = append(res, err) 133 } 134 135 if err := m.validateName(formats); err != nil { 136 res = append(res, err) 137 } 138 139 if err := m.validateParent(formats); err != nil { 140 res = append(res, err) 141 } 142 143 if err := m.validateTaggedVlans(formats); err != nil { 144 res = append(res, err) 145 } 146 147 if err := m.validateTags(formats); err != nil { 148 res = append(res, err) 149 } 150 151 if err := m.validateUntaggedVlan(formats); err != nil { 152 res = append(res, err) 153 } 154 155 if err := m.validateURL(formats); err != nil { 156 res = append(res, err) 157 } 158 159 if err := m.validateVirtualMachine(formats); err != nil { 160 res = append(res, err) 161 } 162 163 if len(res) > 0 { 164 return errors.CompositeValidationError(res...) 165 } 166 return nil 167 } 168 169 func (m *VMInterface) validateCreated(formats strfmt.Registry) error { 170 if swag.IsZero(m.Created) { // not required 171 return nil 172 } 173 174 if err := validate.FormatOf("created", "body", "date", m.Created.String(), formats); err != nil { 175 return err 176 } 177 178 return nil 179 } 180 181 func (m *VMInterface) validateDescription(formats strfmt.Registry) error { 182 if swag.IsZero(m.Description) { // not required 183 return nil 184 } 185 186 if err := validate.MaxLength("description", "body", m.Description, 200); err != nil { 187 return err 188 } 189 190 return nil 191 } 192 193 func (m *VMInterface) validateLastUpdated(formats strfmt.Registry) error { 194 if swag.IsZero(m.LastUpdated) { // not required 195 return nil 196 } 197 198 if err := validate.FormatOf("last_updated", "body", "date-time", m.LastUpdated.String(), formats); err != nil { 199 return err 200 } 201 202 return nil 203 } 204 205 func (m *VMInterface) validateMode(formats strfmt.Registry) error { 206 if swag.IsZero(m.Mode) { // not required 207 return nil 208 } 209 210 if m.Mode != nil { 211 if err := m.Mode.Validate(formats); err != nil { 212 if ve, ok := err.(*errors.Validation); ok { 213 return ve.ValidateName("mode") 214 } else if ce, ok := err.(*errors.CompositeError); ok { 215 return ce.ValidateName("mode") 216 } 217 return err 218 } 219 } 220 221 return nil 222 } 223 224 func (m *VMInterface) validateMtu(formats strfmt.Registry) error { 225 if swag.IsZero(m.Mtu) { // not required 226 return nil 227 } 228 229 if err := validate.MinimumInt("mtu", "body", *m.Mtu, 1, false); err != nil { 230 return err 231 } 232 233 if err := validate.MaximumInt("mtu", "body", *m.Mtu, 65536, false); err != nil { 234 return err 235 } 236 237 return nil 238 } 239 240 func (m *VMInterface) validateName(formats strfmt.Registry) error { 241 242 if err := validate.Required("name", "body", m.Name); err != nil { 243 return err 244 } 245 246 if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { 247 return err 248 } 249 250 if err := validate.MaxLength("name", "body", *m.Name, 64); err != nil { 251 return err 252 } 253 254 return nil 255 } 256 257 func (m *VMInterface) validateParent(formats strfmt.Registry) error { 258 if swag.IsZero(m.Parent) { // not required 259 return nil 260 } 261 262 if m.Parent != nil { 263 if err := m.Parent.Validate(formats); err != nil { 264 if ve, ok := err.(*errors.Validation); ok { 265 return ve.ValidateName("parent") 266 } else if ce, ok := err.(*errors.CompositeError); ok { 267 return ce.ValidateName("parent") 268 } 269 return err 270 } 271 } 272 273 return nil 274 } 275 276 func (m *VMInterface) validateTaggedVlans(formats strfmt.Registry) error { 277 if swag.IsZero(m.TaggedVlans) { // not required 278 return nil 279 } 280 281 if err := validate.UniqueItems("tagged_vlans", "body", m.TaggedVlans); err != nil { 282 return err 283 } 284 285 for i := 0; i < len(m.TaggedVlans); i++ { 286 if swag.IsZero(m.TaggedVlans[i]) { // not required 287 continue 288 } 289 290 if m.TaggedVlans[i] != nil { 291 if err := m.TaggedVlans[i].Validate(formats); err != nil { 292 if ve, ok := err.(*errors.Validation); ok { 293 return ve.ValidateName("tagged_vlans" + "." + strconv.Itoa(i)) 294 } else if ce, ok := err.(*errors.CompositeError); ok { 295 return ce.ValidateName("tagged_vlans" + "." + strconv.Itoa(i)) 296 } 297 return err 298 } 299 } 300 301 } 302 303 return nil 304 } 305 306 func (m *VMInterface) validateTags(formats strfmt.Registry) error { 307 if swag.IsZero(m.Tags) { // not required 308 return nil 309 } 310 311 for i := 0; i < len(m.Tags); i++ { 312 if swag.IsZero(m.Tags[i]) { // not required 313 continue 314 } 315 316 if m.Tags[i] != nil { 317 if err := m.Tags[i].Validate(formats); err != nil { 318 if ve, ok := err.(*errors.Validation); ok { 319 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 320 } else if ce, ok := err.(*errors.CompositeError); ok { 321 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 322 } 323 return err 324 } 325 } 326 327 } 328 329 return nil 330 } 331 332 func (m *VMInterface) validateUntaggedVlan(formats strfmt.Registry) error { 333 if swag.IsZero(m.UntaggedVlan) { // not required 334 return nil 335 } 336 337 if m.UntaggedVlan != nil { 338 if err := m.UntaggedVlan.Validate(formats); err != nil { 339 if ve, ok := err.(*errors.Validation); ok { 340 return ve.ValidateName("untagged_vlan") 341 } else if ce, ok := err.(*errors.CompositeError); ok { 342 return ce.ValidateName("untagged_vlan") 343 } 344 return err 345 } 346 } 347 348 return nil 349 } 350 351 func (m *VMInterface) validateURL(formats strfmt.Registry) error { 352 if swag.IsZero(m.URL) { // not required 353 return nil 354 } 355 356 if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { 357 return err 358 } 359 360 return nil 361 } 362 363 func (m *VMInterface) validateVirtualMachine(formats strfmt.Registry) error { 364 365 if err := validate.Required("virtual_machine", "body", m.VirtualMachine); err != nil { 366 return err 367 } 368 369 if m.VirtualMachine != nil { 370 if err := m.VirtualMachine.Validate(formats); err != nil { 371 if ve, ok := err.(*errors.Validation); ok { 372 return ve.ValidateName("virtual_machine") 373 } else if ce, ok := err.(*errors.CompositeError); ok { 374 return ce.ValidateName("virtual_machine") 375 } 376 return err 377 } 378 } 379 380 return nil 381 } 382 383 // ContextValidate validate this VM interface based on the context it is used 384 func (m *VMInterface) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 385 var res []error 386 387 if err := m.contextValidateCountIpaddresses(ctx, formats); err != nil { 388 res = append(res, err) 389 } 390 391 if err := m.contextValidateCreated(ctx, formats); err != nil { 392 res = append(res, err) 393 } 394 395 if err := m.contextValidateDisplay(ctx, formats); err != nil { 396 res = append(res, err) 397 } 398 399 if err := m.contextValidateID(ctx, formats); err != nil { 400 res = append(res, err) 401 } 402 403 if err := m.contextValidateLastUpdated(ctx, formats); err != nil { 404 res = append(res, err) 405 } 406 407 if err := m.contextValidateMode(ctx, formats); err != nil { 408 res = append(res, err) 409 } 410 411 if err := m.contextValidateParent(ctx, formats); err != nil { 412 res = append(res, err) 413 } 414 415 if err := m.contextValidateTaggedVlans(ctx, formats); err != nil { 416 res = append(res, err) 417 } 418 419 if err := m.contextValidateTags(ctx, formats); err != nil { 420 res = append(res, err) 421 } 422 423 if err := m.contextValidateUntaggedVlan(ctx, formats); err != nil { 424 res = append(res, err) 425 } 426 427 if err := m.contextValidateURL(ctx, formats); err != nil { 428 res = append(res, err) 429 } 430 431 if err := m.contextValidateVirtualMachine(ctx, formats); err != nil { 432 res = append(res, err) 433 } 434 435 if len(res) > 0 { 436 return errors.CompositeValidationError(res...) 437 } 438 return nil 439 } 440 441 func (m *VMInterface) contextValidateCountIpaddresses(ctx context.Context, formats strfmt.Registry) error { 442 443 if err := validate.ReadOnly(ctx, "count_ipaddresses", "body", int64(m.CountIpaddresses)); err != nil { 444 return err 445 } 446 447 return nil 448 } 449 450 func (m *VMInterface) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error { 451 452 if err := validate.ReadOnly(ctx, "created", "body", strfmt.Date(m.Created)); err != nil { 453 return err 454 } 455 456 return nil 457 } 458 459 func (m *VMInterface) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error { 460 461 if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil { 462 return err 463 } 464 465 return nil 466 } 467 468 func (m *VMInterface) contextValidateID(ctx context.Context, formats strfmt.Registry) error { 469 470 if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil { 471 return err 472 } 473 474 return nil 475 } 476 477 func (m *VMInterface) contextValidateLastUpdated(ctx context.Context, formats strfmt.Registry) error { 478 479 if err := validate.ReadOnly(ctx, "last_updated", "body", strfmt.DateTime(m.LastUpdated)); err != nil { 480 return err 481 } 482 483 return nil 484 } 485 486 func (m *VMInterface) contextValidateMode(ctx context.Context, formats strfmt.Registry) error { 487 488 if m.Mode != nil { 489 if err := m.Mode.ContextValidate(ctx, formats); err != nil { 490 if ve, ok := err.(*errors.Validation); ok { 491 return ve.ValidateName("mode") 492 } else if ce, ok := err.(*errors.CompositeError); ok { 493 return ce.ValidateName("mode") 494 } 495 return err 496 } 497 } 498 499 return nil 500 } 501 502 func (m *VMInterface) contextValidateParent(ctx context.Context, formats strfmt.Registry) error { 503 504 if m.Parent != nil { 505 if err := m.Parent.ContextValidate(ctx, formats); err != nil { 506 if ve, ok := err.(*errors.Validation); ok { 507 return ve.ValidateName("parent") 508 } else if ce, ok := err.(*errors.CompositeError); ok { 509 return ce.ValidateName("parent") 510 } 511 return err 512 } 513 } 514 515 return nil 516 } 517 518 func (m *VMInterface) contextValidateTaggedVlans(ctx context.Context, formats strfmt.Registry) error { 519 520 for i := 0; i < len(m.TaggedVlans); i++ { 521 522 if m.TaggedVlans[i] != nil { 523 if err := m.TaggedVlans[i].ContextValidate(ctx, formats); err != nil { 524 if ve, ok := err.(*errors.Validation); ok { 525 return ve.ValidateName("tagged_vlans" + "." + strconv.Itoa(i)) 526 } else if ce, ok := err.(*errors.CompositeError); ok { 527 return ce.ValidateName("tagged_vlans" + "." + strconv.Itoa(i)) 528 } 529 return err 530 } 531 } 532 533 } 534 535 return nil 536 } 537 538 func (m *VMInterface) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { 539 540 for i := 0; i < len(m.Tags); i++ { 541 542 if m.Tags[i] != nil { 543 if err := m.Tags[i].ContextValidate(ctx, formats); err != nil { 544 if ve, ok := err.(*errors.Validation); ok { 545 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 546 } else if ce, ok := err.(*errors.CompositeError); ok { 547 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 548 } 549 return err 550 } 551 } 552 553 } 554 555 return nil 556 } 557 558 func (m *VMInterface) contextValidateUntaggedVlan(ctx context.Context, formats strfmt.Registry) error { 559 560 if m.UntaggedVlan != nil { 561 if err := m.UntaggedVlan.ContextValidate(ctx, formats); err != nil { 562 if ve, ok := err.(*errors.Validation); ok { 563 return ve.ValidateName("untagged_vlan") 564 } else if ce, ok := err.(*errors.CompositeError); ok { 565 return ce.ValidateName("untagged_vlan") 566 } 567 return err 568 } 569 } 570 571 return nil 572 } 573 574 func (m *VMInterface) contextValidateURL(ctx context.Context, formats strfmt.Registry) error { 575 576 if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil { 577 return err 578 } 579 580 return nil 581 } 582 583 func (m *VMInterface) contextValidateVirtualMachine(ctx context.Context, formats strfmt.Registry) error { 584 585 if m.VirtualMachine != nil { 586 if err := m.VirtualMachine.ContextValidate(ctx, formats); err != nil { 587 if ve, ok := err.(*errors.Validation); ok { 588 return ve.ValidateName("virtual_machine") 589 } else if ce, ok := err.(*errors.CompositeError); ok { 590 return ce.ValidateName("virtual_machine") 591 } 592 return err 593 } 594 } 595 596 return nil 597 } 598 599 // MarshalBinary interface implementation 600 func (m *VMInterface) MarshalBinary() ([]byte, error) { 601 if m == nil { 602 return nil, nil 603 } 604 return swag.WriteJSON(m) 605 } 606 607 // UnmarshalBinary interface implementation 608 func (m *VMInterface) UnmarshalBinary(b []byte) error { 609 var res VMInterface 610 if err := swag.ReadJSON(b, &res); err != nil { 611 return err 612 } 613 *m = res 614 return nil 615 } 616 617 // VMInterfaceMode Mode 618 // 619 // swagger:model VMInterfaceMode 620 type VMInterfaceMode struct { 621 622 // label 623 // Required: true 624 // Enum: [Access Tagged Tagged (All)] 625 Label *string `json:"label"` 626 627 // value 628 // Required: true 629 // Enum: [access tagged tagged-all] 630 Value *string `json:"value"` 631 } 632 633 // Validate validates this VM interface mode 634 func (m *VMInterfaceMode) Validate(formats strfmt.Registry) error { 635 var res []error 636 637 if err := m.validateLabel(formats); err != nil { 638 res = append(res, err) 639 } 640 641 if err := m.validateValue(formats); err != nil { 642 res = append(res, err) 643 } 644 645 if len(res) > 0 { 646 return errors.CompositeValidationError(res...) 647 } 648 return nil 649 } 650 651 var vmInterfaceModeTypeLabelPropEnum []interface{} 652 653 func init() { 654 var res []string 655 if err := json.Unmarshal([]byte(`["Access","Tagged","Tagged (All)"]`), &res); err != nil { 656 panic(err) 657 } 658 for _, v := range res { 659 vmInterfaceModeTypeLabelPropEnum = append(vmInterfaceModeTypeLabelPropEnum, v) 660 } 661 } 662 663 const ( 664 665 // VMInterfaceModeLabelAccess captures enum value "Access" 666 VMInterfaceModeLabelAccess string = "Access" 667 668 // VMInterfaceModeLabelTagged captures enum value "Tagged" 669 VMInterfaceModeLabelTagged string = "Tagged" 670 671 // VMInterfaceModeLabelTaggedAll captures enum value "Tagged (All)" 672 VMInterfaceModeLabelTaggedAll string = "Tagged (All)" 673 ) 674 675 // prop value enum 676 func (m *VMInterfaceMode) validateLabelEnum(path, location string, value string) error { 677 if err := validate.EnumCase(path, location, value, vmInterfaceModeTypeLabelPropEnum, true); err != nil { 678 return err 679 } 680 return nil 681 } 682 683 func (m *VMInterfaceMode) validateLabel(formats strfmt.Registry) error { 684 685 if err := validate.Required("mode"+"."+"label", "body", m.Label); err != nil { 686 return err 687 } 688 689 // value enum 690 if err := m.validateLabelEnum("mode"+"."+"label", "body", *m.Label); err != nil { 691 return err 692 } 693 694 return nil 695 } 696 697 var vmInterfaceModeTypeValuePropEnum []interface{} 698 699 func init() { 700 var res []string 701 if err := json.Unmarshal([]byte(`["access","tagged","tagged-all"]`), &res); err != nil { 702 panic(err) 703 } 704 for _, v := range res { 705 vmInterfaceModeTypeValuePropEnum = append(vmInterfaceModeTypeValuePropEnum, v) 706 } 707 } 708 709 const ( 710 711 // VMInterfaceModeValueAccess captures enum value "access" 712 VMInterfaceModeValueAccess string = "access" 713 714 // VMInterfaceModeValueTagged captures enum value "tagged" 715 VMInterfaceModeValueTagged string = "tagged" 716 717 // VMInterfaceModeValueTaggedDashAll captures enum value "tagged-all" 718 VMInterfaceModeValueTaggedDashAll string = "tagged-all" 719 ) 720 721 // prop value enum 722 func (m *VMInterfaceMode) validateValueEnum(path, location string, value string) error { 723 if err := validate.EnumCase(path, location, value, vmInterfaceModeTypeValuePropEnum, true); err != nil { 724 return err 725 } 726 return nil 727 } 728 729 func (m *VMInterfaceMode) validateValue(formats strfmt.Registry) error { 730 731 if err := validate.Required("mode"+"."+"value", "body", m.Value); err != nil { 732 return err 733 } 734 735 // value enum 736 if err := m.validateValueEnum("mode"+"."+"value", "body", *m.Value); err != nil { 737 return err 738 } 739 740 return nil 741 } 742 743 // ContextValidate validates this VM interface mode based on context it is used 744 func (m *VMInterfaceMode) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 745 return nil 746 } 747 748 // MarshalBinary interface implementation 749 func (m *VMInterfaceMode) MarshalBinary() ([]byte, error) { 750 if m == nil { 751 return nil, nil 752 } 753 return swag.WriteJSON(m) 754 } 755 756 // UnmarshalBinary interface implementation 757 func (m *VMInterfaceMode) UnmarshalBinary(b []byte) error { 758 var res VMInterfaceMode 759 if err := swag.ReadJSON(b, &res); err != nil { 760 return err 761 } 762 *m = res 763 return nil 764 }