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