github.com/digitalocean/go-netbox@v0.0.2/netbox/models/writable_front_port.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 // WritableFrontPort writable front port 35 // 36 // swagger:model WritableFrontPort 37 type WritableFrontPort struct { 38 39 // occupied 40 // Read Only: true 41 Occupied *bool `json:"_occupied,omitempty"` 42 43 // cable 44 Cable *NestedCable `json:"cable,omitempty"` 45 46 // Cable peer 47 // 48 // 49 // Return the appropriate serializer for the cable termination model. 50 // 51 // Read Only: true 52 CablePeer map[string]*string `json:"cable_peer,omitempty"` 53 54 // Cable peer type 55 // Read Only: true 56 CablePeerType string `json:"cable_peer_type,omitempty"` 57 58 // Created 59 // Read Only: true 60 // Format: date 61 Created strfmt.Date `json:"created,omitempty"` 62 63 // Custom fields 64 CustomFields interface{} `json:"custom_fields,omitempty"` 65 66 // Description 67 // Max Length: 200 68 Description string `json:"description,omitempty"` 69 70 // Device 71 // Required: true 72 Device *int64 `json:"device"` 73 74 // Display 75 // Read Only: true 76 Display string `json:"display,omitempty"` 77 78 // Id 79 // Read Only: true 80 ID int64 `json:"id,omitempty"` 81 82 // Label 83 // 84 // Physical label 85 // Max Length: 64 86 Label string `json:"label,omitempty"` 87 88 // Last updated 89 // Read Only: true 90 // Format: date-time 91 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"` 92 93 // Mark connected 94 // 95 // Treat as if a cable is connected 96 MarkConnected bool `json:"mark_connected,omitempty"` 97 98 // Name 99 // Required: true 100 // Max Length: 64 101 // Min Length: 1 102 Name *string `json:"name"` 103 104 // Rear port 105 // Required: true 106 RearPort *int64 `json:"rear_port"` 107 108 // Rear port position 109 // Maximum: 1024 110 // Minimum: 1 111 RearPortPosition int64 `json:"rear_port_position,omitempty"` 112 113 // tags 114 Tags []*NestedTag `json:"tags"` 115 116 // Type 117 // Required: true 118 // Enum: [8p8c 8p6c 8p4c 8p2c 6p6c 6p4c 6p2c 4p4c 4p2c gg45 tera-4p tera-2p tera-1p 110-punch bnc f n mrj21 fc lc lc-apc lsh lsh-apc mpo mtrj sc sc-apc st cs sn splice] 119 Type *string `json:"type"` 120 121 // Url 122 // Read Only: true 123 // Format: uri 124 URL strfmt.URI `json:"url,omitempty"` 125 } 126 127 // Validate validates this writable front port 128 func (m *WritableFrontPort) Validate(formats strfmt.Registry) error { 129 var res []error 130 131 if err := m.validateCable(formats); err != nil { 132 res = append(res, err) 133 } 134 135 if err := m.validateCreated(formats); err != nil { 136 res = append(res, err) 137 } 138 139 if err := m.validateDescription(formats); err != nil { 140 res = append(res, err) 141 } 142 143 if err := m.validateDevice(formats); err != nil { 144 res = append(res, err) 145 } 146 147 if err := m.validateLabel(formats); err != nil { 148 res = append(res, err) 149 } 150 151 if err := m.validateLastUpdated(formats); err != nil { 152 res = append(res, err) 153 } 154 155 if err := m.validateName(formats); err != nil { 156 res = append(res, err) 157 } 158 159 if err := m.validateRearPort(formats); err != nil { 160 res = append(res, err) 161 } 162 163 if err := m.validateRearPortPosition(formats); err != nil { 164 res = append(res, err) 165 } 166 167 if err := m.validateTags(formats); err != nil { 168 res = append(res, err) 169 } 170 171 if err := m.validateType(formats); err != nil { 172 res = append(res, err) 173 } 174 175 if err := m.validateURL(formats); err != nil { 176 res = append(res, err) 177 } 178 179 if len(res) > 0 { 180 return errors.CompositeValidationError(res...) 181 } 182 return nil 183 } 184 185 func (m *WritableFrontPort) validateCable(formats strfmt.Registry) error { 186 if swag.IsZero(m.Cable) { // not required 187 return nil 188 } 189 190 if m.Cable != nil { 191 if err := m.Cable.Validate(formats); err != nil { 192 if ve, ok := err.(*errors.Validation); ok { 193 return ve.ValidateName("cable") 194 } else if ce, ok := err.(*errors.CompositeError); ok { 195 return ce.ValidateName("cable") 196 } 197 return err 198 } 199 } 200 201 return nil 202 } 203 204 func (m *WritableFrontPort) validateCreated(formats strfmt.Registry) error { 205 if swag.IsZero(m.Created) { // not required 206 return nil 207 } 208 209 if err := validate.FormatOf("created", "body", "date", m.Created.String(), formats); err != nil { 210 return err 211 } 212 213 return nil 214 } 215 216 func (m *WritableFrontPort) validateDescription(formats strfmt.Registry) error { 217 if swag.IsZero(m.Description) { // not required 218 return nil 219 } 220 221 if err := validate.MaxLength("description", "body", m.Description, 200); err != nil { 222 return err 223 } 224 225 return nil 226 } 227 228 func (m *WritableFrontPort) validateDevice(formats strfmt.Registry) error { 229 230 if err := validate.Required("device", "body", m.Device); err != nil { 231 return err 232 } 233 234 return nil 235 } 236 237 func (m *WritableFrontPort) validateLabel(formats strfmt.Registry) error { 238 if swag.IsZero(m.Label) { // not required 239 return nil 240 } 241 242 if err := validate.MaxLength("label", "body", m.Label, 64); err != nil { 243 return err 244 } 245 246 return nil 247 } 248 249 func (m *WritableFrontPort) validateLastUpdated(formats strfmt.Registry) error { 250 if swag.IsZero(m.LastUpdated) { // not required 251 return nil 252 } 253 254 if err := validate.FormatOf("last_updated", "body", "date-time", m.LastUpdated.String(), formats); err != nil { 255 return err 256 } 257 258 return nil 259 } 260 261 func (m *WritableFrontPort) validateName(formats strfmt.Registry) error { 262 263 if err := validate.Required("name", "body", m.Name); err != nil { 264 return err 265 } 266 267 if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { 268 return err 269 } 270 271 if err := validate.MaxLength("name", "body", *m.Name, 64); err != nil { 272 return err 273 } 274 275 return nil 276 } 277 278 func (m *WritableFrontPort) validateRearPort(formats strfmt.Registry) error { 279 280 if err := validate.Required("rear_port", "body", m.RearPort); err != nil { 281 return err 282 } 283 284 return nil 285 } 286 287 func (m *WritableFrontPort) validateRearPortPosition(formats strfmt.Registry) error { 288 if swag.IsZero(m.RearPortPosition) { // not required 289 return nil 290 } 291 292 if err := validate.MinimumInt("rear_port_position", "body", m.RearPortPosition, 1, false); err != nil { 293 return err 294 } 295 296 if err := validate.MaximumInt("rear_port_position", "body", m.RearPortPosition, 1024, false); err != nil { 297 return err 298 } 299 300 return nil 301 } 302 303 func (m *WritableFrontPort) validateTags(formats strfmt.Registry) error { 304 if swag.IsZero(m.Tags) { // not required 305 return nil 306 } 307 308 for i := 0; i < len(m.Tags); i++ { 309 if swag.IsZero(m.Tags[i]) { // not required 310 continue 311 } 312 313 if m.Tags[i] != nil { 314 if err := m.Tags[i].Validate(formats); err != nil { 315 if ve, ok := err.(*errors.Validation); ok { 316 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 317 } else if ce, ok := err.(*errors.CompositeError); ok { 318 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 319 } 320 return err 321 } 322 } 323 324 } 325 326 return nil 327 } 328 329 var writableFrontPortTypeTypePropEnum []interface{} 330 331 func init() { 332 var res []string 333 if err := json.Unmarshal([]byte(`["8p8c","8p6c","8p4c","8p2c","6p6c","6p4c","6p2c","4p4c","4p2c","gg45","tera-4p","tera-2p","tera-1p","110-punch","bnc","f","n","mrj21","fc","lc","lc-apc","lsh","lsh-apc","mpo","mtrj","sc","sc-apc","st","cs","sn","splice"]`), &res); err != nil { 334 panic(err) 335 } 336 for _, v := range res { 337 writableFrontPortTypeTypePropEnum = append(writableFrontPortTypeTypePropEnum, v) 338 } 339 } 340 341 const ( 342 343 // WritableFrontPortTypeNr8p8c captures enum value "8p8c" 344 WritableFrontPortTypeNr8p8c string = "8p8c" 345 346 // WritableFrontPortTypeNr8p6c captures enum value "8p6c" 347 WritableFrontPortTypeNr8p6c string = "8p6c" 348 349 // WritableFrontPortTypeNr8p4c captures enum value "8p4c" 350 WritableFrontPortTypeNr8p4c string = "8p4c" 351 352 // WritableFrontPortTypeNr8p2c captures enum value "8p2c" 353 WritableFrontPortTypeNr8p2c string = "8p2c" 354 355 // WritableFrontPortTypeNr6p6c captures enum value "6p6c" 356 WritableFrontPortTypeNr6p6c string = "6p6c" 357 358 // WritableFrontPortTypeNr6p4c captures enum value "6p4c" 359 WritableFrontPortTypeNr6p4c string = "6p4c" 360 361 // WritableFrontPortTypeNr6p2c captures enum value "6p2c" 362 WritableFrontPortTypeNr6p2c string = "6p2c" 363 364 // WritableFrontPortTypeNr4p4c captures enum value "4p4c" 365 WritableFrontPortTypeNr4p4c string = "4p4c" 366 367 // WritableFrontPortTypeNr4p2c captures enum value "4p2c" 368 WritableFrontPortTypeNr4p2c string = "4p2c" 369 370 // WritableFrontPortTypeGg45 captures enum value "gg45" 371 WritableFrontPortTypeGg45 string = "gg45" 372 373 // WritableFrontPortTypeTeraDash4p captures enum value "tera-4p" 374 WritableFrontPortTypeTeraDash4p string = "tera-4p" 375 376 // WritableFrontPortTypeTeraDash2p captures enum value "tera-2p" 377 WritableFrontPortTypeTeraDash2p string = "tera-2p" 378 379 // WritableFrontPortTypeTeraDash1p captures enum value "tera-1p" 380 WritableFrontPortTypeTeraDash1p string = "tera-1p" 381 382 // WritableFrontPortTypeNr110DashPunch captures enum value "110-punch" 383 WritableFrontPortTypeNr110DashPunch string = "110-punch" 384 385 // WritableFrontPortTypeBnc captures enum value "bnc" 386 WritableFrontPortTypeBnc string = "bnc" 387 388 // WritableFrontPortTypeF captures enum value "f" 389 WritableFrontPortTypeF string = "f" 390 391 // WritableFrontPortTypeN captures enum value "n" 392 WritableFrontPortTypeN string = "n" 393 394 // WritableFrontPortTypeMrj21 captures enum value "mrj21" 395 WritableFrontPortTypeMrj21 string = "mrj21" 396 397 // WritableFrontPortTypeFc captures enum value "fc" 398 WritableFrontPortTypeFc string = "fc" 399 400 // WritableFrontPortTypeLc captures enum value "lc" 401 WritableFrontPortTypeLc string = "lc" 402 403 // WritableFrontPortTypeLcDashApc captures enum value "lc-apc" 404 WritableFrontPortTypeLcDashApc string = "lc-apc" 405 406 // WritableFrontPortTypeLsh captures enum value "lsh" 407 WritableFrontPortTypeLsh string = "lsh" 408 409 // WritableFrontPortTypeLshDashApc captures enum value "lsh-apc" 410 WritableFrontPortTypeLshDashApc string = "lsh-apc" 411 412 // WritableFrontPortTypeMpo captures enum value "mpo" 413 WritableFrontPortTypeMpo string = "mpo" 414 415 // WritableFrontPortTypeMtrj captures enum value "mtrj" 416 WritableFrontPortTypeMtrj string = "mtrj" 417 418 // WritableFrontPortTypeSc captures enum value "sc" 419 WritableFrontPortTypeSc string = "sc" 420 421 // WritableFrontPortTypeScDashApc captures enum value "sc-apc" 422 WritableFrontPortTypeScDashApc string = "sc-apc" 423 424 // WritableFrontPortTypeSt captures enum value "st" 425 WritableFrontPortTypeSt string = "st" 426 427 // WritableFrontPortTypeCs captures enum value "cs" 428 WritableFrontPortTypeCs string = "cs" 429 430 // WritableFrontPortTypeSn captures enum value "sn" 431 WritableFrontPortTypeSn string = "sn" 432 433 // WritableFrontPortTypeSplice captures enum value "splice" 434 WritableFrontPortTypeSplice string = "splice" 435 ) 436 437 // prop value enum 438 func (m *WritableFrontPort) validateTypeEnum(path, location string, value string) error { 439 if err := validate.EnumCase(path, location, value, writableFrontPortTypeTypePropEnum, true); err != nil { 440 return err 441 } 442 return nil 443 } 444 445 func (m *WritableFrontPort) validateType(formats strfmt.Registry) error { 446 447 if err := validate.Required("type", "body", m.Type); err != nil { 448 return err 449 } 450 451 // value enum 452 if err := m.validateTypeEnum("type", "body", *m.Type); err != nil { 453 return err 454 } 455 456 return nil 457 } 458 459 func (m *WritableFrontPort) validateURL(formats strfmt.Registry) error { 460 if swag.IsZero(m.URL) { // not required 461 return nil 462 } 463 464 if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { 465 return err 466 } 467 468 return nil 469 } 470 471 // ContextValidate validate this writable front port based on the context it is used 472 func (m *WritableFrontPort) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 473 var res []error 474 475 if err := m.contextValidateOccupied(ctx, formats); err != nil { 476 res = append(res, err) 477 } 478 479 if err := m.contextValidateCable(ctx, formats); err != nil { 480 res = append(res, err) 481 } 482 483 if err := m.contextValidateCablePeer(ctx, formats); err != nil { 484 res = append(res, err) 485 } 486 487 if err := m.contextValidateCablePeerType(ctx, formats); err != nil { 488 res = append(res, err) 489 } 490 491 if err := m.contextValidateCreated(ctx, formats); err != nil { 492 res = append(res, err) 493 } 494 495 if err := m.contextValidateDisplay(ctx, formats); err != nil { 496 res = append(res, err) 497 } 498 499 if err := m.contextValidateID(ctx, formats); err != nil { 500 res = append(res, err) 501 } 502 503 if err := m.contextValidateLastUpdated(ctx, formats); err != nil { 504 res = append(res, err) 505 } 506 507 if err := m.contextValidateTags(ctx, formats); err != nil { 508 res = append(res, err) 509 } 510 511 if err := m.contextValidateURL(ctx, formats); err != nil { 512 res = append(res, err) 513 } 514 515 if len(res) > 0 { 516 return errors.CompositeValidationError(res...) 517 } 518 return nil 519 } 520 521 func (m *WritableFrontPort) contextValidateOccupied(ctx context.Context, formats strfmt.Registry) error { 522 523 if err := validate.ReadOnly(ctx, "_occupied", "body", m.Occupied); err != nil { 524 return err 525 } 526 527 return nil 528 } 529 530 func (m *WritableFrontPort) contextValidateCable(ctx context.Context, formats strfmt.Registry) error { 531 532 if m.Cable != nil { 533 if err := m.Cable.ContextValidate(ctx, formats); err != nil { 534 if ve, ok := err.(*errors.Validation); ok { 535 return ve.ValidateName("cable") 536 } else if ce, ok := err.(*errors.CompositeError); ok { 537 return ce.ValidateName("cable") 538 } 539 return err 540 } 541 } 542 543 return nil 544 } 545 546 func (m *WritableFrontPort) contextValidateCablePeer(ctx context.Context, formats strfmt.Registry) error { 547 548 return nil 549 } 550 551 func (m *WritableFrontPort) contextValidateCablePeerType(ctx context.Context, formats strfmt.Registry) error { 552 553 if err := validate.ReadOnly(ctx, "cable_peer_type", "body", string(m.CablePeerType)); err != nil { 554 return err 555 } 556 557 return nil 558 } 559 560 func (m *WritableFrontPort) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error { 561 562 if err := validate.ReadOnly(ctx, "created", "body", strfmt.Date(m.Created)); err != nil { 563 return err 564 } 565 566 return nil 567 } 568 569 func (m *WritableFrontPort) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error { 570 571 if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil { 572 return err 573 } 574 575 return nil 576 } 577 578 func (m *WritableFrontPort) contextValidateID(ctx context.Context, formats strfmt.Registry) error { 579 580 if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil { 581 return err 582 } 583 584 return nil 585 } 586 587 func (m *WritableFrontPort) contextValidateLastUpdated(ctx context.Context, formats strfmt.Registry) error { 588 589 if err := validate.ReadOnly(ctx, "last_updated", "body", strfmt.DateTime(m.LastUpdated)); err != nil { 590 return err 591 } 592 593 return nil 594 } 595 596 func (m *WritableFrontPort) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { 597 598 for i := 0; i < len(m.Tags); i++ { 599 600 if m.Tags[i] != nil { 601 if err := m.Tags[i].ContextValidate(ctx, formats); err != nil { 602 if ve, ok := err.(*errors.Validation); ok { 603 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 604 } else if ce, ok := err.(*errors.CompositeError); ok { 605 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 606 } 607 return err 608 } 609 } 610 611 } 612 613 return nil 614 } 615 616 func (m *WritableFrontPort) contextValidateURL(ctx context.Context, formats strfmt.Registry) error { 617 618 if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil { 619 return err 620 } 621 622 return nil 623 } 624 625 // MarshalBinary interface implementation 626 func (m *WritableFrontPort) MarshalBinary() ([]byte, error) { 627 if m == nil { 628 return nil, nil 629 } 630 return swag.WriteJSON(m) 631 } 632 633 // UnmarshalBinary interface implementation 634 func (m *WritableFrontPort) UnmarshalBinary(b []byte) error { 635 var res WritableFrontPort 636 if err := swag.ReadJSON(b, &res); err != nil { 637 return err 638 } 639 *m = res 640 return nil 641 }