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