github.com/digitalocean/go-netbox@v0.0.2/netbox/models/writable_site.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 // WritableSite writable site 35 // 36 // swagger:model WritableSite 37 type WritableSite struct { 38 39 // ASN 40 // 41 // 32-bit autonomous system number 42 // Maximum: 4.294967295e+09 43 // Minimum: 1 44 Asn *int64 `json:"asn,omitempty"` 45 46 // Circuit count 47 // Read Only: true 48 CircuitCount int64 `json:"circuit_count,omitempty"` 49 50 // Comments 51 Comments string `json:"comments,omitempty"` 52 53 // Contact E-mail 54 // Max Length: 254 55 // Format: email 56 ContactEmail strfmt.Email `json:"contact_email,omitempty"` 57 58 // Contact name 59 // Max Length: 50 60 ContactName string `json:"contact_name,omitempty"` 61 62 // Contact phone 63 // Max Length: 20 64 ContactPhone string `json:"contact_phone,omitempty"` 65 66 // Created 67 // Read Only: true 68 // Format: date 69 Created strfmt.Date `json:"created,omitempty"` 70 71 // Custom fields 72 CustomFields interface{} `json:"custom_fields,omitempty"` 73 74 // Description 75 // Max Length: 200 76 Description string `json:"description,omitempty"` 77 78 // Device count 79 // Read Only: true 80 DeviceCount int64 `json:"device_count,omitempty"` 81 82 // Display 83 // Read Only: true 84 Display string `json:"display,omitempty"` 85 86 // Facility 87 // 88 // Local facility ID or description 89 // Max Length: 50 90 Facility string `json:"facility,omitempty"` 91 92 // Group 93 Group *int64 `json:"group,omitempty"` 94 95 // Id 96 // Read Only: true 97 ID int64 `json:"id,omitempty"` 98 99 // Last updated 100 // Read Only: true 101 // Format: date-time 102 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"` 103 104 // Latitude 105 // 106 // GPS coordinate (latitude) 107 Latitude *string `json:"latitude,omitempty"` 108 109 // Longitude 110 // 111 // GPS coordinate (longitude) 112 Longitude *string `json:"longitude,omitempty"` 113 114 // Name 115 // Required: true 116 // Max Length: 100 117 // Min Length: 1 118 Name *string `json:"name"` 119 120 // Physical address 121 // Max Length: 200 122 PhysicalAddress string `json:"physical_address,omitempty"` 123 124 // Prefix count 125 // Read Only: true 126 PrefixCount int64 `json:"prefix_count,omitempty"` 127 128 // Rack count 129 // Read Only: true 130 RackCount int64 `json:"rack_count,omitempty"` 131 132 // Region 133 Region *int64 `json:"region,omitempty"` 134 135 // Shipping address 136 // Max Length: 200 137 ShippingAddress string `json:"shipping_address,omitempty"` 138 139 // Slug 140 // Required: true 141 // Max Length: 100 142 // Min Length: 1 143 // Pattern: ^[-a-zA-Z0-9_]+$ 144 Slug *string `json:"slug"` 145 146 // Status 147 // Enum: [planned staging active decommissioning retired] 148 Status string `json:"status,omitempty"` 149 150 // tags 151 Tags []*NestedTag `json:"tags"` 152 153 // Tenant 154 Tenant *int64 `json:"tenant,omitempty"` 155 156 // Time zone 157 TimeZone string `json:"time_zone,omitempty"` 158 159 // Url 160 // Read Only: true 161 // Format: uri 162 URL strfmt.URI `json:"url,omitempty"` 163 164 // Virtualmachine count 165 // Read Only: true 166 VirtualmachineCount int64 `json:"virtualmachine_count,omitempty"` 167 168 // Vlan count 169 // Read Only: true 170 VlanCount int64 `json:"vlan_count,omitempty"` 171 } 172 173 // Validate validates this writable site 174 func (m *WritableSite) Validate(formats strfmt.Registry) error { 175 var res []error 176 177 if err := m.validateAsn(formats); err != nil { 178 res = append(res, err) 179 } 180 181 if err := m.validateContactEmail(formats); err != nil { 182 res = append(res, err) 183 } 184 185 if err := m.validateContactName(formats); err != nil { 186 res = append(res, err) 187 } 188 189 if err := m.validateContactPhone(formats); err != nil { 190 res = append(res, err) 191 } 192 193 if err := m.validateCreated(formats); err != nil { 194 res = append(res, err) 195 } 196 197 if err := m.validateDescription(formats); err != nil { 198 res = append(res, err) 199 } 200 201 if err := m.validateFacility(formats); err != nil { 202 res = append(res, err) 203 } 204 205 if err := m.validateLastUpdated(formats); err != nil { 206 res = append(res, err) 207 } 208 209 if err := m.validateName(formats); err != nil { 210 res = append(res, err) 211 } 212 213 if err := m.validatePhysicalAddress(formats); err != nil { 214 res = append(res, err) 215 } 216 217 if err := m.validateShippingAddress(formats); err != nil { 218 res = append(res, err) 219 } 220 221 if err := m.validateSlug(formats); err != nil { 222 res = append(res, err) 223 } 224 225 if err := m.validateStatus(formats); err != nil { 226 res = append(res, err) 227 } 228 229 if err := m.validateTags(formats); err != nil { 230 res = append(res, err) 231 } 232 233 if err := m.validateURL(formats); err != nil { 234 res = append(res, err) 235 } 236 237 if len(res) > 0 { 238 return errors.CompositeValidationError(res...) 239 } 240 return nil 241 } 242 243 func (m *WritableSite) validateAsn(formats strfmt.Registry) error { 244 if swag.IsZero(m.Asn) { // not required 245 return nil 246 } 247 248 if err := validate.MinimumInt("asn", "body", *m.Asn, 1, false); err != nil { 249 return err 250 } 251 252 if err := validate.MaximumInt("asn", "body", *m.Asn, 4.294967295e+09, false); err != nil { 253 return err 254 } 255 256 return nil 257 } 258 259 func (m *WritableSite) validateContactEmail(formats strfmt.Registry) error { 260 if swag.IsZero(m.ContactEmail) { // not required 261 return nil 262 } 263 264 if err := validate.MaxLength("contact_email", "body", m.ContactEmail.String(), 254); err != nil { 265 return err 266 } 267 268 if err := validate.FormatOf("contact_email", "body", "email", m.ContactEmail.String(), formats); err != nil { 269 return err 270 } 271 272 return nil 273 } 274 275 func (m *WritableSite) validateContactName(formats strfmt.Registry) error { 276 if swag.IsZero(m.ContactName) { // not required 277 return nil 278 } 279 280 if err := validate.MaxLength("contact_name", "body", m.ContactName, 50); err != nil { 281 return err 282 } 283 284 return nil 285 } 286 287 func (m *WritableSite) validateContactPhone(formats strfmt.Registry) error { 288 if swag.IsZero(m.ContactPhone) { // not required 289 return nil 290 } 291 292 if err := validate.MaxLength("contact_phone", "body", m.ContactPhone, 20); err != nil { 293 return err 294 } 295 296 return nil 297 } 298 299 func (m *WritableSite) validateCreated(formats strfmt.Registry) error { 300 if swag.IsZero(m.Created) { // not required 301 return nil 302 } 303 304 if err := validate.FormatOf("created", "body", "date", m.Created.String(), formats); err != nil { 305 return err 306 } 307 308 return nil 309 } 310 311 func (m *WritableSite) validateDescription(formats strfmt.Registry) error { 312 if swag.IsZero(m.Description) { // not required 313 return nil 314 } 315 316 if err := validate.MaxLength("description", "body", m.Description, 200); err != nil { 317 return err 318 } 319 320 return nil 321 } 322 323 func (m *WritableSite) validateFacility(formats strfmt.Registry) error { 324 if swag.IsZero(m.Facility) { // not required 325 return nil 326 } 327 328 if err := validate.MaxLength("facility", "body", m.Facility, 50); err != nil { 329 return err 330 } 331 332 return nil 333 } 334 335 func (m *WritableSite) validateLastUpdated(formats strfmt.Registry) error { 336 if swag.IsZero(m.LastUpdated) { // not required 337 return nil 338 } 339 340 if err := validate.FormatOf("last_updated", "body", "date-time", m.LastUpdated.String(), formats); err != nil { 341 return err 342 } 343 344 return nil 345 } 346 347 func (m *WritableSite) validateName(formats strfmt.Registry) error { 348 349 if err := validate.Required("name", "body", m.Name); err != nil { 350 return err 351 } 352 353 if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { 354 return err 355 } 356 357 if err := validate.MaxLength("name", "body", *m.Name, 100); err != nil { 358 return err 359 } 360 361 return nil 362 } 363 364 func (m *WritableSite) validatePhysicalAddress(formats strfmt.Registry) error { 365 if swag.IsZero(m.PhysicalAddress) { // not required 366 return nil 367 } 368 369 if err := validate.MaxLength("physical_address", "body", m.PhysicalAddress, 200); err != nil { 370 return err 371 } 372 373 return nil 374 } 375 376 func (m *WritableSite) validateShippingAddress(formats strfmt.Registry) error { 377 if swag.IsZero(m.ShippingAddress) { // not required 378 return nil 379 } 380 381 if err := validate.MaxLength("shipping_address", "body", m.ShippingAddress, 200); err != nil { 382 return err 383 } 384 385 return nil 386 } 387 388 func (m *WritableSite) validateSlug(formats strfmt.Registry) error { 389 390 if err := validate.Required("slug", "body", m.Slug); err != nil { 391 return err 392 } 393 394 if err := validate.MinLength("slug", "body", *m.Slug, 1); err != nil { 395 return err 396 } 397 398 if err := validate.MaxLength("slug", "body", *m.Slug, 100); err != nil { 399 return err 400 } 401 402 if err := validate.Pattern("slug", "body", *m.Slug, `^[-a-zA-Z0-9_]+$`); err != nil { 403 return err 404 } 405 406 return nil 407 } 408 409 var writableSiteTypeStatusPropEnum []interface{} 410 411 func init() { 412 var res []string 413 if err := json.Unmarshal([]byte(`["planned","staging","active","decommissioning","retired"]`), &res); err != nil { 414 panic(err) 415 } 416 for _, v := range res { 417 writableSiteTypeStatusPropEnum = append(writableSiteTypeStatusPropEnum, v) 418 } 419 } 420 421 const ( 422 423 // WritableSiteStatusPlanned captures enum value "planned" 424 WritableSiteStatusPlanned string = "planned" 425 426 // WritableSiteStatusStaging captures enum value "staging" 427 WritableSiteStatusStaging string = "staging" 428 429 // WritableSiteStatusActive captures enum value "active" 430 WritableSiteStatusActive string = "active" 431 432 // WritableSiteStatusDecommissioning captures enum value "decommissioning" 433 WritableSiteStatusDecommissioning string = "decommissioning" 434 435 // WritableSiteStatusRetired captures enum value "retired" 436 WritableSiteStatusRetired string = "retired" 437 ) 438 439 // prop value enum 440 func (m *WritableSite) validateStatusEnum(path, location string, value string) error { 441 if err := validate.EnumCase(path, location, value, writableSiteTypeStatusPropEnum, true); err != nil { 442 return err 443 } 444 return nil 445 } 446 447 func (m *WritableSite) validateStatus(formats strfmt.Registry) error { 448 if swag.IsZero(m.Status) { // not required 449 return nil 450 } 451 452 // value enum 453 if err := m.validateStatusEnum("status", "body", m.Status); err != nil { 454 return err 455 } 456 457 return nil 458 } 459 460 func (m *WritableSite) validateTags(formats strfmt.Registry) error { 461 if swag.IsZero(m.Tags) { // not required 462 return nil 463 } 464 465 for i := 0; i < len(m.Tags); i++ { 466 if swag.IsZero(m.Tags[i]) { // not required 467 continue 468 } 469 470 if m.Tags[i] != nil { 471 if err := m.Tags[i].Validate(formats); err != nil { 472 if ve, ok := err.(*errors.Validation); ok { 473 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 474 } else if ce, ok := err.(*errors.CompositeError); ok { 475 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 476 } 477 return err 478 } 479 } 480 481 } 482 483 return nil 484 } 485 486 func (m *WritableSite) validateURL(formats strfmt.Registry) error { 487 if swag.IsZero(m.URL) { // not required 488 return nil 489 } 490 491 if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { 492 return err 493 } 494 495 return nil 496 } 497 498 // ContextValidate validate this writable site based on the context it is used 499 func (m *WritableSite) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 500 var res []error 501 502 if err := m.contextValidateCircuitCount(ctx, formats); err != nil { 503 res = append(res, err) 504 } 505 506 if err := m.contextValidateCreated(ctx, formats); err != nil { 507 res = append(res, err) 508 } 509 510 if err := m.contextValidateDeviceCount(ctx, formats); err != nil { 511 res = append(res, err) 512 } 513 514 if err := m.contextValidateDisplay(ctx, formats); err != nil { 515 res = append(res, err) 516 } 517 518 if err := m.contextValidateID(ctx, formats); err != nil { 519 res = append(res, err) 520 } 521 522 if err := m.contextValidateLastUpdated(ctx, formats); err != nil { 523 res = append(res, err) 524 } 525 526 if err := m.contextValidatePrefixCount(ctx, formats); err != nil { 527 res = append(res, err) 528 } 529 530 if err := m.contextValidateRackCount(ctx, formats); err != nil { 531 res = append(res, err) 532 } 533 534 if err := m.contextValidateTags(ctx, formats); err != nil { 535 res = append(res, err) 536 } 537 538 if err := m.contextValidateURL(ctx, formats); err != nil { 539 res = append(res, err) 540 } 541 542 if err := m.contextValidateVirtualmachineCount(ctx, formats); err != nil { 543 res = append(res, err) 544 } 545 546 if err := m.contextValidateVlanCount(ctx, formats); err != nil { 547 res = append(res, err) 548 } 549 550 if len(res) > 0 { 551 return errors.CompositeValidationError(res...) 552 } 553 return nil 554 } 555 556 func (m *WritableSite) contextValidateCircuitCount(ctx context.Context, formats strfmt.Registry) error { 557 558 if err := validate.ReadOnly(ctx, "circuit_count", "body", int64(m.CircuitCount)); err != nil { 559 return err 560 } 561 562 return nil 563 } 564 565 func (m *WritableSite) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error { 566 567 if err := validate.ReadOnly(ctx, "created", "body", strfmt.Date(m.Created)); err != nil { 568 return err 569 } 570 571 return nil 572 } 573 574 func (m *WritableSite) contextValidateDeviceCount(ctx context.Context, formats strfmt.Registry) error { 575 576 if err := validate.ReadOnly(ctx, "device_count", "body", int64(m.DeviceCount)); err != nil { 577 return err 578 } 579 580 return nil 581 } 582 583 func (m *WritableSite) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error { 584 585 if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil { 586 return err 587 } 588 589 return nil 590 } 591 592 func (m *WritableSite) contextValidateID(ctx context.Context, formats strfmt.Registry) error { 593 594 if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil { 595 return err 596 } 597 598 return nil 599 } 600 601 func (m *WritableSite) contextValidateLastUpdated(ctx context.Context, formats strfmt.Registry) error { 602 603 if err := validate.ReadOnly(ctx, "last_updated", "body", strfmt.DateTime(m.LastUpdated)); err != nil { 604 return err 605 } 606 607 return nil 608 } 609 610 func (m *WritableSite) contextValidatePrefixCount(ctx context.Context, formats strfmt.Registry) error { 611 612 if err := validate.ReadOnly(ctx, "prefix_count", "body", int64(m.PrefixCount)); err != nil { 613 return err 614 } 615 616 return nil 617 } 618 619 func (m *WritableSite) contextValidateRackCount(ctx context.Context, formats strfmt.Registry) error { 620 621 if err := validate.ReadOnly(ctx, "rack_count", "body", int64(m.RackCount)); err != nil { 622 return err 623 } 624 625 return nil 626 } 627 628 func (m *WritableSite) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { 629 630 for i := 0; i < len(m.Tags); i++ { 631 632 if m.Tags[i] != nil { 633 if err := m.Tags[i].ContextValidate(ctx, formats); err != nil { 634 if ve, ok := err.(*errors.Validation); ok { 635 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 636 } else if ce, ok := err.(*errors.CompositeError); ok { 637 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 638 } 639 return err 640 } 641 } 642 643 } 644 645 return nil 646 } 647 648 func (m *WritableSite) contextValidateURL(ctx context.Context, formats strfmt.Registry) error { 649 650 if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil { 651 return err 652 } 653 654 return nil 655 } 656 657 func (m *WritableSite) contextValidateVirtualmachineCount(ctx context.Context, formats strfmt.Registry) error { 658 659 if err := validate.ReadOnly(ctx, "virtualmachine_count", "body", int64(m.VirtualmachineCount)); err != nil { 660 return err 661 } 662 663 return nil 664 } 665 666 func (m *WritableSite) contextValidateVlanCount(ctx context.Context, formats strfmt.Registry) error { 667 668 if err := validate.ReadOnly(ctx, "vlan_count", "body", int64(m.VlanCount)); err != nil { 669 return err 670 } 671 672 return nil 673 } 674 675 // MarshalBinary interface implementation 676 func (m *WritableSite) MarshalBinary() ([]byte, error) { 677 if m == nil { 678 return nil, nil 679 } 680 return swag.WriteJSON(m) 681 } 682 683 // UnmarshalBinary interface implementation 684 func (m *WritableSite) UnmarshalBinary(b []byte) error { 685 var res WritableSite 686 if err := swag.ReadJSON(b, &res); err != nil { 687 return err 688 } 689 *m = res 690 return nil 691 }