github.com/digitalocean/go-netbox@v0.0.2/netbox/models/writable_rack.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 // Copyright 2020 The go-netbox Authors. 4 // 5 // Licensed under the Apache License, Version 2.0 (the "License"); 6 // you may not use this file except in compliance with the License. 7 // You may obtain a copy of the License at 8 // 9 // http://www.apache.org/licenses/LICENSE-2.0 10 // 11 // Unless required by applicable law or agreed to in writing, software 12 // distributed under the License is distributed on an "AS IS" BASIS, 13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 // See the License for the specific language governing permissions and 15 // limitations under the License. 16 // 17 18 package models 19 20 // This file was generated by the swagger tool. 21 // Editing this file might prove futile when you re-run the swagger generate command 22 23 import ( 24 "context" 25 "encoding/json" 26 "strconv" 27 28 "github.com/go-openapi/errors" 29 "github.com/go-openapi/strfmt" 30 "github.com/go-openapi/swag" 31 "github.com/go-openapi/validate" 32 ) 33 34 // WritableRack writable rack 35 // 36 // swagger:model WritableRack 37 type WritableRack struct { 38 39 // Asset tag 40 // 41 // A unique tag used to identify this rack 42 // Max Length: 50 43 AssetTag *string `json:"asset_tag,omitempty"` 44 45 // Comments 46 Comments string `json:"comments,omitempty"` 47 48 // Created 49 // Read Only: true 50 // Format: date 51 Created strfmt.Date `json:"created,omitempty"` 52 53 // Custom fields 54 CustomFields interface{} `json:"custom_fields,omitempty"` 55 56 // Descending units 57 // 58 // Units are numbered top-to-bottom 59 DescUnits bool `json:"desc_units,omitempty"` 60 61 // Device count 62 // Read Only: true 63 DeviceCount int64 `json:"device_count,omitempty"` 64 65 // Display 66 // Read Only: true 67 Display string `json:"display,omitempty"` 68 69 // Display name 70 // Read Only: true 71 DisplayName string `json:"display_name,omitempty"` 72 73 // Facility ID 74 // 75 // Locally-assigned identifier 76 // Max Length: 50 77 FacilityID *string `json:"facility_id,omitempty"` 78 79 // Id 80 // Read Only: true 81 ID int64 `json:"id,omitempty"` 82 83 // Last updated 84 // Read Only: true 85 // Format: date-time 86 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"` 87 88 // Location 89 Location *int64 `json:"location,omitempty"` 90 91 // Name 92 // Required: true 93 // Max Length: 100 94 // Min Length: 1 95 Name *string `json:"name"` 96 97 // Outer depth 98 // 99 // Outer dimension of rack (depth) 100 // Maximum: 32767 101 // Minimum: 0 102 OuterDepth *int64 `json:"outer_depth,omitempty"` 103 104 // Outer unit 105 // Enum: [mm in] 106 OuterUnit string `json:"outer_unit,omitempty"` 107 108 // Outer width 109 // 110 // Outer dimension of rack (width) 111 // Maximum: 32767 112 // Minimum: 0 113 OuterWidth *int64 `json:"outer_width,omitempty"` 114 115 // Powerfeed count 116 // Read Only: true 117 PowerfeedCount int64 `json:"powerfeed_count,omitempty"` 118 119 // Role 120 // 121 // Functional role 122 Role *int64 `json:"role,omitempty"` 123 124 // Serial number 125 // Max Length: 50 126 Serial string `json:"serial,omitempty"` 127 128 // Site 129 // Required: true 130 Site *int64 `json:"site"` 131 132 // Status 133 // Enum: [reserved available planned active deprecated] 134 Status string `json:"status,omitempty"` 135 136 // tags 137 Tags []*NestedTag `json:"tags"` 138 139 // Tenant 140 Tenant *int64 `json:"tenant,omitempty"` 141 142 // Type 143 // Enum: [2-post-frame 4-post-frame 4-post-cabinet wall-frame wall-cabinet] 144 Type string `json:"type,omitempty"` 145 146 // Height (U) 147 // 148 // Height in rack units 149 // Maximum: 100 150 // Minimum: 1 151 UHeight int64 `json:"u_height,omitempty"` 152 153 // Url 154 // Read Only: true 155 // Format: uri 156 URL strfmt.URI `json:"url,omitempty"` 157 158 // Width 159 // 160 // Rail-to-rail width 161 // Enum: [10 19 21 23] 162 Width int64 `json:"width,omitempty"` 163 } 164 165 // Validate validates this writable rack 166 func (m *WritableRack) Validate(formats strfmt.Registry) error { 167 var res []error 168 169 if err := m.validateAssetTag(formats); err != nil { 170 res = append(res, err) 171 } 172 173 if err := m.validateCreated(formats); err != nil { 174 res = append(res, err) 175 } 176 177 if err := m.validateFacilityID(formats); err != nil { 178 res = append(res, err) 179 } 180 181 if err := m.validateLastUpdated(formats); err != nil { 182 res = append(res, err) 183 } 184 185 if err := m.validateName(formats); err != nil { 186 res = append(res, err) 187 } 188 189 if err := m.validateOuterDepth(formats); err != nil { 190 res = append(res, err) 191 } 192 193 if err := m.validateOuterUnit(formats); err != nil { 194 res = append(res, err) 195 } 196 197 if err := m.validateOuterWidth(formats); err != nil { 198 res = append(res, err) 199 } 200 201 if err := m.validateSerial(formats); err != nil { 202 res = append(res, err) 203 } 204 205 if err := m.validateSite(formats); err != nil { 206 res = append(res, err) 207 } 208 209 if err := m.validateStatus(formats); err != nil { 210 res = append(res, err) 211 } 212 213 if err := m.validateTags(formats); err != nil { 214 res = append(res, err) 215 } 216 217 if err := m.validateType(formats); err != nil { 218 res = append(res, err) 219 } 220 221 if err := m.validateUHeight(formats); err != nil { 222 res = append(res, err) 223 } 224 225 if err := m.validateURL(formats); err != nil { 226 res = append(res, err) 227 } 228 229 if err := m.validateWidth(formats); err != nil { 230 res = append(res, err) 231 } 232 233 if len(res) > 0 { 234 return errors.CompositeValidationError(res...) 235 } 236 return nil 237 } 238 239 func (m *WritableRack) validateAssetTag(formats strfmt.Registry) error { 240 if swag.IsZero(m.AssetTag) { // not required 241 return nil 242 } 243 244 if err := validate.MaxLength("asset_tag", "body", *m.AssetTag, 50); err != nil { 245 return err 246 } 247 248 return nil 249 } 250 251 func (m *WritableRack) validateCreated(formats strfmt.Registry) error { 252 if swag.IsZero(m.Created) { // not required 253 return nil 254 } 255 256 if err := validate.FormatOf("created", "body", "date", m.Created.String(), formats); err != nil { 257 return err 258 } 259 260 return nil 261 } 262 263 func (m *WritableRack) validateFacilityID(formats strfmt.Registry) error { 264 if swag.IsZero(m.FacilityID) { // not required 265 return nil 266 } 267 268 if err := validate.MaxLength("facility_id", "body", *m.FacilityID, 50); err != nil { 269 return err 270 } 271 272 return nil 273 } 274 275 func (m *WritableRack) validateLastUpdated(formats strfmt.Registry) error { 276 if swag.IsZero(m.LastUpdated) { // not required 277 return nil 278 } 279 280 if err := validate.FormatOf("last_updated", "body", "date-time", m.LastUpdated.String(), formats); err != nil { 281 return err 282 } 283 284 return nil 285 } 286 287 func (m *WritableRack) validateName(formats strfmt.Registry) error { 288 289 if err := validate.Required("name", "body", m.Name); err != nil { 290 return err 291 } 292 293 if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { 294 return err 295 } 296 297 if err := validate.MaxLength("name", "body", *m.Name, 100); err != nil { 298 return err 299 } 300 301 return nil 302 } 303 304 func (m *WritableRack) validateOuterDepth(formats strfmt.Registry) error { 305 if swag.IsZero(m.OuterDepth) { // not required 306 return nil 307 } 308 309 if err := validate.MinimumInt("outer_depth", "body", *m.OuterDepth, 0, false); err != nil { 310 return err 311 } 312 313 if err := validate.MaximumInt("outer_depth", "body", *m.OuterDepth, 32767, false); err != nil { 314 return err 315 } 316 317 return nil 318 } 319 320 var writableRackTypeOuterUnitPropEnum []interface{} 321 322 func init() { 323 var res []string 324 if err := json.Unmarshal([]byte(`["mm","in"]`), &res); err != nil { 325 panic(err) 326 } 327 for _, v := range res { 328 writableRackTypeOuterUnitPropEnum = append(writableRackTypeOuterUnitPropEnum, v) 329 } 330 } 331 332 const ( 333 334 // WritableRackOuterUnitMm captures enum value "mm" 335 WritableRackOuterUnitMm string = "mm" 336 337 // WritableRackOuterUnitIn captures enum value "in" 338 WritableRackOuterUnitIn string = "in" 339 ) 340 341 // prop value enum 342 func (m *WritableRack) validateOuterUnitEnum(path, location string, value string) error { 343 if err := validate.EnumCase(path, location, value, writableRackTypeOuterUnitPropEnum, true); err != nil { 344 return err 345 } 346 return nil 347 } 348 349 func (m *WritableRack) validateOuterUnit(formats strfmt.Registry) error { 350 if swag.IsZero(m.OuterUnit) { // not required 351 return nil 352 } 353 354 // value enum 355 if err := m.validateOuterUnitEnum("outer_unit", "body", m.OuterUnit); err != nil { 356 return err 357 } 358 359 return nil 360 } 361 362 func (m *WritableRack) validateOuterWidth(formats strfmt.Registry) error { 363 if swag.IsZero(m.OuterWidth) { // not required 364 return nil 365 } 366 367 if err := validate.MinimumInt("outer_width", "body", *m.OuterWidth, 0, false); err != nil { 368 return err 369 } 370 371 if err := validate.MaximumInt("outer_width", "body", *m.OuterWidth, 32767, false); err != nil { 372 return err 373 } 374 375 return nil 376 } 377 378 func (m *WritableRack) validateSerial(formats strfmt.Registry) error { 379 if swag.IsZero(m.Serial) { // not required 380 return nil 381 } 382 383 if err := validate.MaxLength("serial", "body", m.Serial, 50); err != nil { 384 return err 385 } 386 387 return nil 388 } 389 390 func (m *WritableRack) validateSite(formats strfmt.Registry) error { 391 392 if err := validate.Required("site", "body", m.Site); err != nil { 393 return err 394 } 395 396 return nil 397 } 398 399 var writableRackTypeStatusPropEnum []interface{} 400 401 func init() { 402 var res []string 403 if err := json.Unmarshal([]byte(`["reserved","available","planned","active","deprecated"]`), &res); err != nil { 404 panic(err) 405 } 406 for _, v := range res { 407 writableRackTypeStatusPropEnum = append(writableRackTypeStatusPropEnum, v) 408 } 409 } 410 411 const ( 412 413 // WritableRackStatusReserved captures enum value "reserved" 414 WritableRackStatusReserved string = "reserved" 415 416 // WritableRackStatusAvailable captures enum value "available" 417 WritableRackStatusAvailable string = "available" 418 419 // WritableRackStatusPlanned captures enum value "planned" 420 WritableRackStatusPlanned string = "planned" 421 422 // WritableRackStatusActive captures enum value "active" 423 WritableRackStatusActive string = "active" 424 425 // WritableRackStatusDeprecated captures enum value "deprecated" 426 WritableRackStatusDeprecated string = "deprecated" 427 ) 428 429 // prop value enum 430 func (m *WritableRack) validateStatusEnum(path, location string, value string) error { 431 if err := validate.EnumCase(path, location, value, writableRackTypeStatusPropEnum, true); err != nil { 432 return err 433 } 434 return nil 435 } 436 437 func (m *WritableRack) validateStatus(formats strfmt.Registry) error { 438 if swag.IsZero(m.Status) { // not required 439 return nil 440 } 441 442 // value enum 443 if err := m.validateStatusEnum("status", "body", m.Status); err != nil { 444 return err 445 } 446 447 return nil 448 } 449 450 func (m *WritableRack) validateTags(formats strfmt.Registry) error { 451 if swag.IsZero(m.Tags) { // not required 452 return nil 453 } 454 455 for i := 0; i < len(m.Tags); i++ { 456 if swag.IsZero(m.Tags[i]) { // not required 457 continue 458 } 459 460 if m.Tags[i] != nil { 461 if err := m.Tags[i].Validate(formats); err != nil { 462 if ve, ok := err.(*errors.Validation); ok { 463 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 464 } else if ce, ok := err.(*errors.CompositeError); ok { 465 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 466 } 467 return err 468 } 469 } 470 471 } 472 473 return nil 474 } 475 476 var writableRackTypeTypePropEnum []interface{} 477 478 func init() { 479 var res []string 480 if err := json.Unmarshal([]byte(`["2-post-frame","4-post-frame","4-post-cabinet","wall-frame","wall-cabinet"]`), &res); err != nil { 481 panic(err) 482 } 483 for _, v := range res { 484 writableRackTypeTypePropEnum = append(writableRackTypeTypePropEnum, v) 485 } 486 } 487 488 const ( 489 490 // WritableRackTypeNr2DashPostDashFrame captures enum value "2-post-frame" 491 WritableRackTypeNr2DashPostDashFrame string = "2-post-frame" 492 493 // WritableRackTypeNr4DashPostDashFrame captures enum value "4-post-frame" 494 WritableRackTypeNr4DashPostDashFrame string = "4-post-frame" 495 496 // WritableRackTypeNr4DashPostDashCabinet captures enum value "4-post-cabinet" 497 WritableRackTypeNr4DashPostDashCabinet string = "4-post-cabinet" 498 499 // WritableRackTypeWallDashFrame captures enum value "wall-frame" 500 WritableRackTypeWallDashFrame string = "wall-frame" 501 502 // WritableRackTypeWallDashCabinet captures enum value "wall-cabinet" 503 WritableRackTypeWallDashCabinet string = "wall-cabinet" 504 ) 505 506 // prop value enum 507 func (m *WritableRack) validateTypeEnum(path, location string, value string) error { 508 if err := validate.EnumCase(path, location, value, writableRackTypeTypePropEnum, true); err != nil { 509 return err 510 } 511 return nil 512 } 513 514 func (m *WritableRack) validateType(formats strfmt.Registry) error { 515 if swag.IsZero(m.Type) { // not required 516 return nil 517 } 518 519 // value enum 520 if err := m.validateTypeEnum("type", "body", m.Type); err != nil { 521 return err 522 } 523 524 return nil 525 } 526 527 func (m *WritableRack) validateUHeight(formats strfmt.Registry) error { 528 if swag.IsZero(m.UHeight) { // not required 529 return nil 530 } 531 532 if err := validate.MinimumInt("u_height", "body", m.UHeight, 1, false); err != nil { 533 return err 534 } 535 536 if err := validate.MaximumInt("u_height", "body", m.UHeight, 100, false); err != nil { 537 return err 538 } 539 540 return nil 541 } 542 543 func (m *WritableRack) validateURL(formats strfmt.Registry) error { 544 if swag.IsZero(m.URL) { // not required 545 return nil 546 } 547 548 if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { 549 return err 550 } 551 552 return nil 553 } 554 555 var writableRackTypeWidthPropEnum []interface{} 556 557 func init() { 558 var res []int64 559 if err := json.Unmarshal([]byte(`[10,19,21,23]`), &res); err != nil { 560 panic(err) 561 } 562 for _, v := range res { 563 writableRackTypeWidthPropEnum = append(writableRackTypeWidthPropEnum, v) 564 } 565 } 566 567 // prop value enum 568 func (m *WritableRack) validateWidthEnum(path, location string, value int64) error { 569 if err := validate.EnumCase(path, location, value, writableRackTypeWidthPropEnum, true); err != nil { 570 return err 571 } 572 return nil 573 } 574 575 func (m *WritableRack) validateWidth(formats strfmt.Registry) error { 576 if swag.IsZero(m.Width) { // not required 577 return nil 578 } 579 580 // value enum 581 if err := m.validateWidthEnum("width", "body", m.Width); err != nil { 582 return err 583 } 584 585 return nil 586 } 587 588 // ContextValidate validate this writable rack based on the context it is used 589 func (m *WritableRack) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 590 var res []error 591 592 if err := m.contextValidateCreated(ctx, formats); err != nil { 593 res = append(res, err) 594 } 595 596 if err := m.contextValidateDeviceCount(ctx, formats); err != nil { 597 res = append(res, err) 598 } 599 600 if err := m.contextValidateDisplay(ctx, formats); err != nil { 601 res = append(res, err) 602 } 603 604 if err := m.contextValidateDisplayName(ctx, formats); err != nil { 605 res = append(res, err) 606 } 607 608 if err := m.contextValidateID(ctx, formats); err != nil { 609 res = append(res, err) 610 } 611 612 if err := m.contextValidateLastUpdated(ctx, formats); err != nil { 613 res = append(res, err) 614 } 615 616 if err := m.contextValidatePowerfeedCount(ctx, formats); err != nil { 617 res = append(res, err) 618 } 619 620 if err := m.contextValidateTags(ctx, formats); err != nil { 621 res = append(res, err) 622 } 623 624 if err := m.contextValidateURL(ctx, formats); err != nil { 625 res = append(res, err) 626 } 627 628 if len(res) > 0 { 629 return errors.CompositeValidationError(res...) 630 } 631 return nil 632 } 633 634 func (m *WritableRack) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error { 635 636 if err := validate.ReadOnly(ctx, "created", "body", strfmt.Date(m.Created)); err != nil { 637 return err 638 } 639 640 return nil 641 } 642 643 func (m *WritableRack) contextValidateDeviceCount(ctx context.Context, formats strfmt.Registry) error { 644 645 if err := validate.ReadOnly(ctx, "device_count", "body", int64(m.DeviceCount)); err != nil { 646 return err 647 } 648 649 return nil 650 } 651 652 func (m *WritableRack) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error { 653 654 if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil { 655 return err 656 } 657 658 return nil 659 } 660 661 func (m *WritableRack) contextValidateDisplayName(ctx context.Context, formats strfmt.Registry) error { 662 663 if err := validate.ReadOnly(ctx, "display_name", "body", string(m.DisplayName)); err != nil { 664 return err 665 } 666 667 return nil 668 } 669 670 func (m *WritableRack) contextValidateID(ctx context.Context, formats strfmt.Registry) error { 671 672 if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil { 673 return err 674 } 675 676 return nil 677 } 678 679 func (m *WritableRack) contextValidateLastUpdated(ctx context.Context, formats strfmt.Registry) error { 680 681 if err := validate.ReadOnly(ctx, "last_updated", "body", strfmt.DateTime(m.LastUpdated)); err != nil { 682 return err 683 } 684 685 return nil 686 } 687 688 func (m *WritableRack) contextValidatePowerfeedCount(ctx context.Context, formats strfmt.Registry) error { 689 690 if err := validate.ReadOnly(ctx, "powerfeed_count", "body", int64(m.PowerfeedCount)); err != nil { 691 return err 692 } 693 694 return nil 695 } 696 697 func (m *WritableRack) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { 698 699 for i := 0; i < len(m.Tags); i++ { 700 701 if m.Tags[i] != nil { 702 if err := m.Tags[i].ContextValidate(ctx, formats); err != nil { 703 if ve, ok := err.(*errors.Validation); ok { 704 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 705 } else if ce, ok := err.(*errors.CompositeError); ok { 706 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 707 } 708 return err 709 } 710 } 711 712 } 713 714 return nil 715 } 716 717 func (m *WritableRack) contextValidateURL(ctx context.Context, formats strfmt.Registry) error { 718 719 if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil { 720 return err 721 } 722 723 return nil 724 } 725 726 // MarshalBinary interface implementation 727 func (m *WritableRack) MarshalBinary() ([]byte, error) { 728 if m == nil { 729 return nil, nil 730 } 731 return swag.WriteJSON(m) 732 } 733 734 // UnmarshalBinary interface implementation 735 func (m *WritableRack) UnmarshalBinary(b []byte) error { 736 var res WritableRack 737 if err := swag.ReadJSON(b, &res); err != nil { 738 return err 739 } 740 *m = res 741 return nil 742 }