github.com/digitalocean/go-netbox@v0.0.2/netbox/models/console_server_port_template.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 27 "github.com/go-openapi/errors" 28 "github.com/go-openapi/strfmt" 29 "github.com/go-openapi/swag" 30 "github.com/go-openapi/validate" 31 ) 32 33 // ConsoleServerPortTemplate console server port template 34 // 35 // swagger:model ConsoleServerPortTemplate 36 type ConsoleServerPortTemplate struct { 37 38 // Created 39 // Read Only: true 40 // Format: date 41 Created strfmt.Date `json:"created,omitempty"` 42 43 // Description 44 // Max Length: 200 45 Description string `json:"description,omitempty"` 46 47 // device type 48 // Required: true 49 DeviceType *NestedDeviceType `json:"device_type"` 50 51 // Display 52 // Read Only: true 53 Display string `json:"display,omitempty"` 54 55 // Id 56 // Read Only: true 57 ID int64 `json:"id,omitempty"` 58 59 // Label 60 // 61 // Physical label 62 // Max Length: 64 63 Label string `json:"label,omitempty"` 64 65 // Last updated 66 // Read Only: true 67 // Format: date-time 68 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"` 69 70 // Name 71 // Required: true 72 // Max Length: 64 73 // Min Length: 1 74 Name *string `json:"name"` 75 76 // type 77 Type *ConsoleServerPortTemplateType `json:"type,omitempty"` 78 79 // Url 80 // Read Only: true 81 // Format: uri 82 URL strfmt.URI `json:"url,omitempty"` 83 } 84 85 // Validate validates this console server port template 86 func (m *ConsoleServerPortTemplate) Validate(formats strfmt.Registry) error { 87 var res []error 88 89 if err := m.validateCreated(formats); err != nil { 90 res = append(res, err) 91 } 92 93 if err := m.validateDescription(formats); err != nil { 94 res = append(res, err) 95 } 96 97 if err := m.validateDeviceType(formats); err != nil { 98 res = append(res, err) 99 } 100 101 if err := m.validateLabel(formats); err != nil { 102 res = append(res, err) 103 } 104 105 if err := m.validateLastUpdated(formats); err != nil { 106 res = append(res, err) 107 } 108 109 if err := m.validateName(formats); err != nil { 110 res = append(res, err) 111 } 112 113 if err := m.validateType(formats); err != nil { 114 res = append(res, err) 115 } 116 117 if err := m.validateURL(formats); err != nil { 118 res = append(res, err) 119 } 120 121 if len(res) > 0 { 122 return errors.CompositeValidationError(res...) 123 } 124 return nil 125 } 126 127 func (m *ConsoleServerPortTemplate) validateCreated(formats strfmt.Registry) error { 128 if swag.IsZero(m.Created) { // not required 129 return nil 130 } 131 132 if err := validate.FormatOf("created", "body", "date", m.Created.String(), formats); err != nil { 133 return err 134 } 135 136 return nil 137 } 138 139 func (m *ConsoleServerPortTemplate) validateDescription(formats strfmt.Registry) error { 140 if swag.IsZero(m.Description) { // not required 141 return nil 142 } 143 144 if err := validate.MaxLength("description", "body", m.Description, 200); err != nil { 145 return err 146 } 147 148 return nil 149 } 150 151 func (m *ConsoleServerPortTemplate) validateDeviceType(formats strfmt.Registry) error { 152 153 if err := validate.Required("device_type", "body", m.DeviceType); err != nil { 154 return err 155 } 156 157 if m.DeviceType != nil { 158 if err := m.DeviceType.Validate(formats); err != nil { 159 if ve, ok := err.(*errors.Validation); ok { 160 return ve.ValidateName("device_type") 161 } else if ce, ok := err.(*errors.CompositeError); ok { 162 return ce.ValidateName("device_type") 163 } 164 return err 165 } 166 } 167 168 return nil 169 } 170 171 func (m *ConsoleServerPortTemplate) validateLabel(formats strfmt.Registry) error { 172 if swag.IsZero(m.Label) { // not required 173 return nil 174 } 175 176 if err := validate.MaxLength("label", "body", m.Label, 64); err != nil { 177 return err 178 } 179 180 return nil 181 } 182 183 func (m *ConsoleServerPortTemplate) validateLastUpdated(formats strfmt.Registry) error { 184 if swag.IsZero(m.LastUpdated) { // not required 185 return nil 186 } 187 188 if err := validate.FormatOf("last_updated", "body", "date-time", m.LastUpdated.String(), formats); err != nil { 189 return err 190 } 191 192 return nil 193 } 194 195 func (m *ConsoleServerPortTemplate) validateName(formats strfmt.Registry) error { 196 197 if err := validate.Required("name", "body", m.Name); err != nil { 198 return err 199 } 200 201 if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { 202 return err 203 } 204 205 if err := validate.MaxLength("name", "body", *m.Name, 64); err != nil { 206 return err 207 } 208 209 return nil 210 } 211 212 func (m *ConsoleServerPortTemplate) validateType(formats strfmt.Registry) error { 213 if swag.IsZero(m.Type) { // not required 214 return nil 215 } 216 217 if m.Type != nil { 218 if err := m.Type.Validate(formats); err != nil { 219 if ve, ok := err.(*errors.Validation); ok { 220 return ve.ValidateName("type") 221 } else if ce, ok := err.(*errors.CompositeError); ok { 222 return ce.ValidateName("type") 223 } 224 return err 225 } 226 } 227 228 return nil 229 } 230 231 func (m *ConsoleServerPortTemplate) validateURL(formats strfmt.Registry) error { 232 if swag.IsZero(m.URL) { // not required 233 return nil 234 } 235 236 if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { 237 return err 238 } 239 240 return nil 241 } 242 243 // ContextValidate validate this console server port template based on the context it is used 244 func (m *ConsoleServerPortTemplate) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 245 var res []error 246 247 if err := m.contextValidateCreated(ctx, formats); err != nil { 248 res = append(res, err) 249 } 250 251 if err := m.contextValidateDeviceType(ctx, formats); err != nil { 252 res = append(res, err) 253 } 254 255 if err := m.contextValidateDisplay(ctx, formats); err != nil { 256 res = append(res, err) 257 } 258 259 if err := m.contextValidateID(ctx, formats); err != nil { 260 res = append(res, err) 261 } 262 263 if err := m.contextValidateLastUpdated(ctx, formats); err != nil { 264 res = append(res, err) 265 } 266 267 if err := m.contextValidateType(ctx, formats); err != nil { 268 res = append(res, err) 269 } 270 271 if err := m.contextValidateURL(ctx, formats); err != nil { 272 res = append(res, err) 273 } 274 275 if len(res) > 0 { 276 return errors.CompositeValidationError(res...) 277 } 278 return nil 279 } 280 281 func (m *ConsoleServerPortTemplate) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error { 282 283 if err := validate.ReadOnly(ctx, "created", "body", strfmt.Date(m.Created)); err != nil { 284 return err 285 } 286 287 return nil 288 } 289 290 func (m *ConsoleServerPortTemplate) contextValidateDeviceType(ctx context.Context, formats strfmt.Registry) error { 291 292 if m.DeviceType != nil { 293 if err := m.DeviceType.ContextValidate(ctx, formats); err != nil { 294 if ve, ok := err.(*errors.Validation); ok { 295 return ve.ValidateName("device_type") 296 } else if ce, ok := err.(*errors.CompositeError); ok { 297 return ce.ValidateName("device_type") 298 } 299 return err 300 } 301 } 302 303 return nil 304 } 305 306 func (m *ConsoleServerPortTemplate) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error { 307 308 if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil { 309 return err 310 } 311 312 return nil 313 } 314 315 func (m *ConsoleServerPortTemplate) contextValidateID(ctx context.Context, formats strfmt.Registry) error { 316 317 if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil { 318 return err 319 } 320 321 return nil 322 } 323 324 func (m *ConsoleServerPortTemplate) contextValidateLastUpdated(ctx context.Context, formats strfmt.Registry) error { 325 326 if err := validate.ReadOnly(ctx, "last_updated", "body", strfmt.DateTime(m.LastUpdated)); err != nil { 327 return err 328 } 329 330 return nil 331 } 332 333 func (m *ConsoleServerPortTemplate) contextValidateType(ctx context.Context, formats strfmt.Registry) error { 334 335 if m.Type != nil { 336 if err := m.Type.ContextValidate(ctx, formats); err != nil { 337 if ve, ok := err.(*errors.Validation); ok { 338 return ve.ValidateName("type") 339 } else if ce, ok := err.(*errors.CompositeError); ok { 340 return ce.ValidateName("type") 341 } 342 return err 343 } 344 } 345 346 return nil 347 } 348 349 func (m *ConsoleServerPortTemplate) contextValidateURL(ctx context.Context, formats strfmt.Registry) error { 350 351 if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil { 352 return err 353 } 354 355 return nil 356 } 357 358 // MarshalBinary interface implementation 359 func (m *ConsoleServerPortTemplate) MarshalBinary() ([]byte, error) { 360 if m == nil { 361 return nil, nil 362 } 363 return swag.WriteJSON(m) 364 } 365 366 // UnmarshalBinary interface implementation 367 func (m *ConsoleServerPortTemplate) UnmarshalBinary(b []byte) error { 368 var res ConsoleServerPortTemplate 369 if err := swag.ReadJSON(b, &res); err != nil { 370 return err 371 } 372 *m = res 373 return nil 374 } 375 376 // ConsoleServerPortTemplateType Type 377 // 378 // swagger:model ConsoleServerPortTemplateType 379 type ConsoleServerPortTemplateType struct { 380 381 // label 382 // Required: true 383 // Enum: [DE-9 DB-25 RJ-11 RJ-12 RJ-45 USB Type A USB Type B USB Type C USB Mini A USB Mini B USB Micro A USB Micro B Other] 384 Label *string `json:"label"` 385 386 // value 387 // Required: true 388 // Enum: [de-9 db-25 rj-11 rj-12 rj-45 usb-a usb-b usb-c usb-mini-a usb-mini-b usb-micro-a usb-micro-b other] 389 Value *string `json:"value"` 390 } 391 392 // Validate validates this console server port template type 393 func (m *ConsoleServerPortTemplateType) Validate(formats strfmt.Registry) error { 394 var res []error 395 396 if err := m.validateLabel(formats); err != nil { 397 res = append(res, err) 398 } 399 400 if err := m.validateValue(formats); err != nil { 401 res = append(res, err) 402 } 403 404 if len(res) > 0 { 405 return errors.CompositeValidationError(res...) 406 } 407 return nil 408 } 409 410 var consoleServerPortTemplateTypeTypeLabelPropEnum []interface{} 411 412 func init() { 413 var res []string 414 if err := json.Unmarshal([]byte(`["DE-9","DB-25","RJ-11","RJ-12","RJ-45","USB Type A","USB Type B","USB Type C","USB Mini A","USB Mini B","USB Micro A","USB Micro B","Other"]`), &res); err != nil { 415 panic(err) 416 } 417 for _, v := range res { 418 consoleServerPortTemplateTypeTypeLabelPropEnum = append(consoleServerPortTemplateTypeTypeLabelPropEnum, v) 419 } 420 } 421 422 const ( 423 424 // ConsoleServerPortTemplateTypeLabelDEDash9 captures enum value "DE-9" 425 ConsoleServerPortTemplateTypeLabelDEDash9 string = "DE-9" 426 427 // ConsoleServerPortTemplateTypeLabelDBDash25 captures enum value "DB-25" 428 ConsoleServerPortTemplateTypeLabelDBDash25 string = "DB-25" 429 430 // ConsoleServerPortTemplateTypeLabelRJDash11 captures enum value "RJ-11" 431 ConsoleServerPortTemplateTypeLabelRJDash11 string = "RJ-11" 432 433 // ConsoleServerPortTemplateTypeLabelRJDash12 captures enum value "RJ-12" 434 ConsoleServerPortTemplateTypeLabelRJDash12 string = "RJ-12" 435 436 // ConsoleServerPortTemplateTypeLabelRJDash45 captures enum value "RJ-45" 437 ConsoleServerPortTemplateTypeLabelRJDash45 string = "RJ-45" 438 439 // ConsoleServerPortTemplateTypeLabelUSBTypeA captures enum value "USB Type A" 440 ConsoleServerPortTemplateTypeLabelUSBTypeA string = "USB Type A" 441 442 // ConsoleServerPortTemplateTypeLabelUSBTypeB captures enum value "USB Type B" 443 ConsoleServerPortTemplateTypeLabelUSBTypeB string = "USB Type B" 444 445 // ConsoleServerPortTemplateTypeLabelUSBTypeC captures enum value "USB Type C" 446 ConsoleServerPortTemplateTypeLabelUSBTypeC string = "USB Type C" 447 448 // ConsoleServerPortTemplateTypeLabelUSBMiniA captures enum value "USB Mini A" 449 ConsoleServerPortTemplateTypeLabelUSBMiniA string = "USB Mini A" 450 451 // ConsoleServerPortTemplateTypeLabelUSBMiniB captures enum value "USB Mini B" 452 ConsoleServerPortTemplateTypeLabelUSBMiniB string = "USB Mini B" 453 454 // ConsoleServerPortTemplateTypeLabelUSBMicroA captures enum value "USB Micro A" 455 ConsoleServerPortTemplateTypeLabelUSBMicroA string = "USB Micro A" 456 457 // ConsoleServerPortTemplateTypeLabelUSBMicroB captures enum value "USB Micro B" 458 ConsoleServerPortTemplateTypeLabelUSBMicroB string = "USB Micro B" 459 460 // ConsoleServerPortTemplateTypeLabelOther captures enum value "Other" 461 ConsoleServerPortTemplateTypeLabelOther string = "Other" 462 ) 463 464 // prop value enum 465 func (m *ConsoleServerPortTemplateType) validateLabelEnum(path, location string, value string) error { 466 if err := validate.EnumCase(path, location, value, consoleServerPortTemplateTypeTypeLabelPropEnum, true); err != nil { 467 return err 468 } 469 return nil 470 } 471 472 func (m *ConsoleServerPortTemplateType) validateLabel(formats strfmt.Registry) error { 473 474 if err := validate.Required("type"+"."+"label", "body", m.Label); err != nil { 475 return err 476 } 477 478 // value enum 479 if err := m.validateLabelEnum("type"+"."+"label", "body", *m.Label); err != nil { 480 return err 481 } 482 483 return nil 484 } 485 486 var consoleServerPortTemplateTypeTypeValuePropEnum []interface{} 487 488 func init() { 489 var res []string 490 if err := json.Unmarshal([]byte(`["de-9","db-25","rj-11","rj-12","rj-45","usb-a","usb-b","usb-c","usb-mini-a","usb-mini-b","usb-micro-a","usb-micro-b","other"]`), &res); err != nil { 491 panic(err) 492 } 493 for _, v := range res { 494 consoleServerPortTemplateTypeTypeValuePropEnum = append(consoleServerPortTemplateTypeTypeValuePropEnum, v) 495 } 496 } 497 498 const ( 499 500 // ConsoleServerPortTemplateTypeValueDeDash9 captures enum value "de-9" 501 ConsoleServerPortTemplateTypeValueDeDash9 string = "de-9" 502 503 // ConsoleServerPortTemplateTypeValueDbDash25 captures enum value "db-25" 504 ConsoleServerPortTemplateTypeValueDbDash25 string = "db-25" 505 506 // ConsoleServerPortTemplateTypeValueRjDash11 captures enum value "rj-11" 507 ConsoleServerPortTemplateTypeValueRjDash11 string = "rj-11" 508 509 // ConsoleServerPortTemplateTypeValueRjDash12 captures enum value "rj-12" 510 ConsoleServerPortTemplateTypeValueRjDash12 string = "rj-12" 511 512 // ConsoleServerPortTemplateTypeValueRjDash45 captures enum value "rj-45" 513 ConsoleServerPortTemplateTypeValueRjDash45 string = "rj-45" 514 515 // ConsoleServerPortTemplateTypeValueUsbDasha captures enum value "usb-a" 516 ConsoleServerPortTemplateTypeValueUsbDasha string = "usb-a" 517 518 // ConsoleServerPortTemplateTypeValueUsbDashb captures enum value "usb-b" 519 ConsoleServerPortTemplateTypeValueUsbDashb string = "usb-b" 520 521 // ConsoleServerPortTemplateTypeValueUsbDashc captures enum value "usb-c" 522 ConsoleServerPortTemplateTypeValueUsbDashc string = "usb-c" 523 524 // ConsoleServerPortTemplateTypeValueUsbDashMiniDasha captures enum value "usb-mini-a" 525 ConsoleServerPortTemplateTypeValueUsbDashMiniDasha string = "usb-mini-a" 526 527 // ConsoleServerPortTemplateTypeValueUsbDashMiniDashb captures enum value "usb-mini-b" 528 ConsoleServerPortTemplateTypeValueUsbDashMiniDashb string = "usb-mini-b" 529 530 // ConsoleServerPortTemplateTypeValueUsbDashMicroDasha captures enum value "usb-micro-a" 531 ConsoleServerPortTemplateTypeValueUsbDashMicroDasha string = "usb-micro-a" 532 533 // ConsoleServerPortTemplateTypeValueUsbDashMicroDashb captures enum value "usb-micro-b" 534 ConsoleServerPortTemplateTypeValueUsbDashMicroDashb string = "usb-micro-b" 535 536 // ConsoleServerPortTemplateTypeValueOther captures enum value "other" 537 ConsoleServerPortTemplateTypeValueOther string = "other" 538 ) 539 540 // prop value enum 541 func (m *ConsoleServerPortTemplateType) validateValueEnum(path, location string, value string) error { 542 if err := validate.EnumCase(path, location, value, consoleServerPortTemplateTypeTypeValuePropEnum, true); err != nil { 543 return err 544 } 545 return nil 546 } 547 548 func (m *ConsoleServerPortTemplateType) validateValue(formats strfmt.Registry) error { 549 550 if err := validate.Required("type"+"."+"value", "body", m.Value); err != nil { 551 return err 552 } 553 554 // value enum 555 if err := m.validateValueEnum("type"+"."+"value", "body", *m.Value); err != nil { 556 return err 557 } 558 559 return nil 560 } 561 562 // ContextValidate validates this console server port template type based on context it is used 563 func (m *ConsoleServerPortTemplateType) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 564 return nil 565 } 566 567 // MarshalBinary interface implementation 568 func (m *ConsoleServerPortTemplateType) MarshalBinary() ([]byte, error) { 569 if m == nil { 570 return nil, nil 571 } 572 return swag.WriteJSON(m) 573 } 574 575 // UnmarshalBinary interface implementation 576 func (m *ConsoleServerPortTemplateType) UnmarshalBinary(b []byte) error { 577 var res ConsoleServerPortTemplateType 578 if err := swag.ReadJSON(b, &res); err != nil { 579 return err 580 } 581 *m = res 582 return nil 583 }