github.com/digitalocean/go-netbox@v0.0.2/netbox/models/writable_cable.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 // WritableCable writable cable 35 // 36 // swagger:model WritableCable 37 type WritableCable struct { 38 39 // Color 40 // Max Length: 6 41 // Pattern: ^[0-9a-f]{6}$ 42 Color string `json:"color,omitempty"` 43 44 // Custom fields 45 CustomFields interface{} `json:"custom_fields,omitempty"` 46 47 // Display 48 // Read Only: true 49 Display string `json:"display,omitempty"` 50 51 // Id 52 // Read Only: true 53 ID int64 `json:"id,omitempty"` 54 55 // Label 56 // Max Length: 100 57 Label string `json:"label,omitempty"` 58 59 // Length 60 // Maximum: 32767 61 // Minimum: 0 62 Length *int64 `json:"length,omitempty"` 63 64 // Length unit 65 // Enum: [m cm ft in] 66 LengthUnit string `json:"length_unit,omitempty"` 67 68 // Status 69 // Enum: [connected planned decommissioning] 70 Status string `json:"status,omitempty"` 71 72 // tags 73 Tags []*NestedTag `json:"tags"` 74 75 // Termination a 76 // Read Only: true 77 Terminationa map[string]*string `json:"termination_a,omitempty"` 78 79 // Termination a id 80 // Required: true 81 // Maximum: 2.147483647e+09 82 // Minimum: 0 83 TerminationaID *int64 `json:"termination_a_id"` 84 85 // Termination a type 86 // Required: true 87 TerminationaType *string `json:"termination_a_type"` 88 89 // Termination b 90 // Read Only: true 91 Terminationb map[string]*string `json:"termination_b,omitempty"` 92 93 // Termination b id 94 // Required: true 95 // Maximum: 2.147483647e+09 96 // Minimum: 0 97 TerminationbID *int64 `json:"termination_b_id"` 98 99 // Termination b type 100 // Required: true 101 TerminationbType *string `json:"termination_b_type"` 102 103 // Type 104 // Enum: [cat3 cat5 cat5e cat6 cat6a cat7 cat7a cat8 dac-active dac-passive mrj21-trunk coaxial mmf mmf-om1 mmf-om2 mmf-om3 mmf-om4 mmf-om5 smf smf-os1 smf-os2 aoc power] 105 Type string `json:"type,omitempty"` 106 107 // Url 108 // Read Only: true 109 // Format: uri 110 URL strfmt.URI `json:"url,omitempty"` 111 } 112 113 // Validate validates this writable cable 114 func (m *WritableCable) Validate(formats strfmt.Registry) error { 115 var res []error 116 117 if err := m.validateColor(formats); err != nil { 118 res = append(res, err) 119 } 120 121 if err := m.validateLabel(formats); err != nil { 122 res = append(res, err) 123 } 124 125 if err := m.validateLength(formats); err != nil { 126 res = append(res, err) 127 } 128 129 if err := m.validateLengthUnit(formats); err != nil { 130 res = append(res, err) 131 } 132 133 if err := m.validateStatus(formats); err != nil { 134 res = append(res, err) 135 } 136 137 if err := m.validateTags(formats); err != nil { 138 res = append(res, err) 139 } 140 141 if err := m.validateTerminationaID(formats); err != nil { 142 res = append(res, err) 143 } 144 145 if err := m.validateTerminationaType(formats); err != nil { 146 res = append(res, err) 147 } 148 149 if err := m.validateTerminationbID(formats); err != nil { 150 res = append(res, err) 151 } 152 153 if err := m.validateTerminationbType(formats); err != nil { 154 res = append(res, err) 155 } 156 157 if err := m.validateType(formats); err != nil { 158 res = append(res, err) 159 } 160 161 if err := m.validateURL(formats); err != nil { 162 res = append(res, err) 163 } 164 165 if len(res) > 0 { 166 return errors.CompositeValidationError(res...) 167 } 168 return nil 169 } 170 171 func (m *WritableCable) validateColor(formats strfmt.Registry) error { 172 if swag.IsZero(m.Color) { // not required 173 return nil 174 } 175 176 if err := validate.MaxLength("color", "body", m.Color, 6); err != nil { 177 return err 178 } 179 180 if err := validate.Pattern("color", "body", m.Color, `^[0-9a-f]{6}$`); err != nil { 181 return err 182 } 183 184 return nil 185 } 186 187 func (m *WritableCable) validateLabel(formats strfmt.Registry) error { 188 if swag.IsZero(m.Label) { // not required 189 return nil 190 } 191 192 if err := validate.MaxLength("label", "body", m.Label, 100); err != nil { 193 return err 194 } 195 196 return nil 197 } 198 199 func (m *WritableCable) validateLength(formats strfmt.Registry) error { 200 if swag.IsZero(m.Length) { // not required 201 return nil 202 } 203 204 if err := validate.MinimumInt("length", "body", *m.Length, 0, false); err != nil { 205 return err 206 } 207 208 if err := validate.MaximumInt("length", "body", *m.Length, 32767, false); err != nil { 209 return err 210 } 211 212 return nil 213 } 214 215 var writableCableTypeLengthUnitPropEnum []interface{} 216 217 func init() { 218 var res []string 219 if err := json.Unmarshal([]byte(`["m","cm","ft","in"]`), &res); err != nil { 220 panic(err) 221 } 222 for _, v := range res { 223 writableCableTypeLengthUnitPropEnum = append(writableCableTypeLengthUnitPropEnum, v) 224 } 225 } 226 227 const ( 228 229 // WritableCableLengthUnitM captures enum value "m" 230 WritableCableLengthUnitM string = "m" 231 232 // WritableCableLengthUnitCm captures enum value "cm" 233 WritableCableLengthUnitCm string = "cm" 234 235 // WritableCableLengthUnitFt captures enum value "ft" 236 WritableCableLengthUnitFt string = "ft" 237 238 // WritableCableLengthUnitIn captures enum value "in" 239 WritableCableLengthUnitIn string = "in" 240 ) 241 242 // prop value enum 243 func (m *WritableCable) validateLengthUnitEnum(path, location string, value string) error { 244 if err := validate.EnumCase(path, location, value, writableCableTypeLengthUnitPropEnum, true); err != nil { 245 return err 246 } 247 return nil 248 } 249 250 func (m *WritableCable) validateLengthUnit(formats strfmt.Registry) error { 251 if swag.IsZero(m.LengthUnit) { // not required 252 return nil 253 } 254 255 // value enum 256 if err := m.validateLengthUnitEnum("length_unit", "body", m.LengthUnit); err != nil { 257 return err 258 } 259 260 return nil 261 } 262 263 var writableCableTypeStatusPropEnum []interface{} 264 265 func init() { 266 var res []string 267 if err := json.Unmarshal([]byte(`["connected","planned","decommissioning"]`), &res); err != nil { 268 panic(err) 269 } 270 for _, v := range res { 271 writableCableTypeStatusPropEnum = append(writableCableTypeStatusPropEnum, v) 272 } 273 } 274 275 const ( 276 277 // WritableCableStatusConnected captures enum value "connected" 278 WritableCableStatusConnected string = "connected" 279 280 // WritableCableStatusPlanned captures enum value "planned" 281 WritableCableStatusPlanned string = "planned" 282 283 // WritableCableStatusDecommissioning captures enum value "decommissioning" 284 WritableCableStatusDecommissioning string = "decommissioning" 285 ) 286 287 // prop value enum 288 func (m *WritableCable) validateStatusEnum(path, location string, value string) error { 289 if err := validate.EnumCase(path, location, value, writableCableTypeStatusPropEnum, true); err != nil { 290 return err 291 } 292 return nil 293 } 294 295 func (m *WritableCable) validateStatus(formats strfmt.Registry) error { 296 if swag.IsZero(m.Status) { // not required 297 return nil 298 } 299 300 // value enum 301 if err := m.validateStatusEnum("status", "body", m.Status); err != nil { 302 return err 303 } 304 305 return nil 306 } 307 308 func (m *WritableCable) validateTags(formats strfmt.Registry) error { 309 if swag.IsZero(m.Tags) { // not required 310 return nil 311 } 312 313 for i := 0; i < len(m.Tags); i++ { 314 if swag.IsZero(m.Tags[i]) { // not required 315 continue 316 } 317 318 if m.Tags[i] != nil { 319 if err := m.Tags[i].Validate(formats); err != nil { 320 if ve, ok := err.(*errors.Validation); ok { 321 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 322 } else if ce, ok := err.(*errors.CompositeError); ok { 323 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 324 } 325 return err 326 } 327 } 328 329 } 330 331 return nil 332 } 333 334 func (m *WritableCable) validateTerminationaID(formats strfmt.Registry) error { 335 336 if err := validate.Required("termination_a_id", "body", m.TerminationaID); err != nil { 337 return err 338 } 339 340 if err := validate.MinimumInt("termination_a_id", "body", *m.TerminationaID, 0, false); err != nil { 341 return err 342 } 343 344 if err := validate.MaximumInt("termination_a_id", "body", *m.TerminationaID, 2.147483647e+09, false); err != nil { 345 return err 346 } 347 348 return nil 349 } 350 351 func (m *WritableCable) validateTerminationaType(formats strfmt.Registry) error { 352 353 if err := validate.Required("termination_a_type", "body", m.TerminationaType); err != nil { 354 return err 355 } 356 357 return nil 358 } 359 360 func (m *WritableCable) validateTerminationbID(formats strfmt.Registry) error { 361 362 if err := validate.Required("termination_b_id", "body", m.TerminationbID); err != nil { 363 return err 364 } 365 366 if err := validate.MinimumInt("termination_b_id", "body", *m.TerminationbID, 0, false); err != nil { 367 return err 368 } 369 370 if err := validate.MaximumInt("termination_b_id", "body", *m.TerminationbID, 2.147483647e+09, false); err != nil { 371 return err 372 } 373 374 return nil 375 } 376 377 func (m *WritableCable) validateTerminationbType(formats strfmt.Registry) error { 378 379 if err := validate.Required("termination_b_type", "body", m.TerminationbType); err != nil { 380 return err 381 } 382 383 return nil 384 } 385 386 var writableCableTypeTypePropEnum []interface{} 387 388 func init() { 389 var res []string 390 if err := json.Unmarshal([]byte(`["cat3","cat5","cat5e","cat6","cat6a","cat7","cat7a","cat8","dac-active","dac-passive","mrj21-trunk","coaxial","mmf","mmf-om1","mmf-om2","mmf-om3","mmf-om4","mmf-om5","smf","smf-os1","smf-os2","aoc","power"]`), &res); err != nil { 391 panic(err) 392 } 393 for _, v := range res { 394 writableCableTypeTypePropEnum = append(writableCableTypeTypePropEnum, v) 395 } 396 } 397 398 const ( 399 400 // WritableCableTypeCat3 captures enum value "cat3" 401 WritableCableTypeCat3 string = "cat3" 402 403 // WritableCableTypeCat5 captures enum value "cat5" 404 WritableCableTypeCat5 string = "cat5" 405 406 // WritableCableTypeCat5e captures enum value "cat5e" 407 WritableCableTypeCat5e string = "cat5e" 408 409 // WritableCableTypeCat6 captures enum value "cat6" 410 WritableCableTypeCat6 string = "cat6" 411 412 // WritableCableTypeCat6a captures enum value "cat6a" 413 WritableCableTypeCat6a string = "cat6a" 414 415 // WritableCableTypeCat7 captures enum value "cat7" 416 WritableCableTypeCat7 string = "cat7" 417 418 // WritableCableTypeCat7a captures enum value "cat7a" 419 WritableCableTypeCat7a string = "cat7a" 420 421 // WritableCableTypeCat8 captures enum value "cat8" 422 WritableCableTypeCat8 string = "cat8" 423 424 // WritableCableTypeDacDashActive captures enum value "dac-active" 425 WritableCableTypeDacDashActive string = "dac-active" 426 427 // WritableCableTypeDacDashPassive captures enum value "dac-passive" 428 WritableCableTypeDacDashPassive string = "dac-passive" 429 430 // WritableCableTypeMrj21DashTrunk captures enum value "mrj21-trunk" 431 WritableCableTypeMrj21DashTrunk string = "mrj21-trunk" 432 433 // WritableCableTypeCoaxial captures enum value "coaxial" 434 WritableCableTypeCoaxial string = "coaxial" 435 436 // WritableCableTypeMmf captures enum value "mmf" 437 WritableCableTypeMmf string = "mmf" 438 439 // WritableCableTypeMmfDashOm1 captures enum value "mmf-om1" 440 WritableCableTypeMmfDashOm1 string = "mmf-om1" 441 442 // WritableCableTypeMmfDashOm2 captures enum value "mmf-om2" 443 WritableCableTypeMmfDashOm2 string = "mmf-om2" 444 445 // WritableCableTypeMmfDashOm3 captures enum value "mmf-om3" 446 WritableCableTypeMmfDashOm3 string = "mmf-om3" 447 448 // WritableCableTypeMmfDashOm4 captures enum value "mmf-om4" 449 WritableCableTypeMmfDashOm4 string = "mmf-om4" 450 451 // WritableCableTypeMmfDashOm5 captures enum value "mmf-om5" 452 WritableCableTypeMmfDashOm5 string = "mmf-om5" 453 454 // WritableCableTypeSmf captures enum value "smf" 455 WritableCableTypeSmf string = "smf" 456 457 // WritableCableTypeSmfDashOs1 captures enum value "smf-os1" 458 WritableCableTypeSmfDashOs1 string = "smf-os1" 459 460 // WritableCableTypeSmfDashOs2 captures enum value "smf-os2" 461 WritableCableTypeSmfDashOs2 string = "smf-os2" 462 463 // WritableCableTypeAoc captures enum value "aoc" 464 WritableCableTypeAoc string = "aoc" 465 466 // WritableCableTypePower captures enum value "power" 467 WritableCableTypePower string = "power" 468 ) 469 470 // prop value enum 471 func (m *WritableCable) validateTypeEnum(path, location string, value string) error { 472 if err := validate.EnumCase(path, location, value, writableCableTypeTypePropEnum, true); err != nil { 473 return err 474 } 475 return nil 476 } 477 478 func (m *WritableCable) validateType(formats strfmt.Registry) error { 479 if swag.IsZero(m.Type) { // not required 480 return nil 481 } 482 483 // value enum 484 if err := m.validateTypeEnum("type", "body", m.Type); err != nil { 485 return err 486 } 487 488 return nil 489 } 490 491 func (m *WritableCable) validateURL(formats strfmt.Registry) error { 492 if swag.IsZero(m.URL) { // not required 493 return nil 494 } 495 496 if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { 497 return err 498 } 499 500 return nil 501 } 502 503 // ContextValidate validate this writable cable based on the context it is used 504 func (m *WritableCable) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 505 var res []error 506 507 if err := m.contextValidateDisplay(ctx, formats); err != nil { 508 res = append(res, err) 509 } 510 511 if err := m.contextValidateID(ctx, formats); err != nil { 512 res = append(res, err) 513 } 514 515 if err := m.contextValidateTags(ctx, formats); err != nil { 516 res = append(res, err) 517 } 518 519 if err := m.contextValidateTerminationa(ctx, formats); err != nil { 520 res = append(res, err) 521 } 522 523 if err := m.contextValidateTerminationb(ctx, formats); err != nil { 524 res = append(res, err) 525 } 526 527 if err := m.contextValidateURL(ctx, formats); err != nil { 528 res = append(res, err) 529 } 530 531 if len(res) > 0 { 532 return errors.CompositeValidationError(res...) 533 } 534 return nil 535 } 536 537 func (m *WritableCable) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error { 538 539 if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil { 540 return err 541 } 542 543 return nil 544 } 545 546 func (m *WritableCable) contextValidateID(ctx context.Context, formats strfmt.Registry) error { 547 548 if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil { 549 return err 550 } 551 552 return nil 553 } 554 555 func (m *WritableCable) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { 556 557 for i := 0; i < len(m.Tags); i++ { 558 559 if m.Tags[i] != nil { 560 if err := m.Tags[i].ContextValidate(ctx, formats); err != nil { 561 if ve, ok := err.(*errors.Validation); ok { 562 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 563 } else if ce, ok := err.(*errors.CompositeError); ok { 564 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 565 } 566 return err 567 } 568 } 569 570 } 571 572 return nil 573 } 574 575 func (m *WritableCable) contextValidateTerminationa(ctx context.Context, formats strfmt.Registry) error { 576 577 return nil 578 } 579 580 func (m *WritableCable) contextValidateTerminationb(ctx context.Context, formats strfmt.Registry) error { 581 582 return nil 583 } 584 585 func (m *WritableCable) 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 *WritableCable) 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 *WritableCable) UnmarshalBinary(b []byte) error { 604 var res WritableCable 605 if err := swag.ReadJSON(b, &res); err != nil { 606 return err 607 } 608 *m = res 609 return nil 610 }