github.com/digitalocean/go-netbox@v0.0.2/netbox/models/circuit_termination.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 // CircuitTermination circuit termination 34 // 35 // swagger:model CircuitTermination 36 type CircuitTermination struct { 37 38 // occupied 39 // Read Only: true 40 Occupied *bool `json:"_occupied,omitempty"` 41 42 // cable 43 Cable *NestedCable `json:"cable,omitempty"` 44 45 // Cable peer 46 // 47 // 48 // Return the appropriate serializer for the cable termination model. 49 // 50 // Read Only: true 51 CablePeer map[string]*string `json:"cable_peer,omitempty"` 52 53 // Cable peer type 54 // Read Only: true 55 CablePeerType string `json:"cable_peer_type,omitempty"` 56 57 // circuit 58 // Required: true 59 Circuit *NestedCircuit `json:"circuit"` 60 61 // Description 62 // Max Length: 200 63 Description string `json:"description,omitempty"` 64 65 // Display 66 // Read Only: true 67 Display string `json:"display,omitempty"` 68 69 // Id 70 // Read Only: true 71 ID int64 `json:"id,omitempty"` 72 73 // Mark connected 74 // 75 // Treat as if a cable is connected 76 MarkConnected bool `json:"mark_connected,omitempty"` 77 78 // Port speed (Kbps) 79 // Maximum: 2.147483647e+09 80 // Minimum: 0 81 PortSpeed *int64 `json:"port_speed,omitempty"` 82 83 // Patch panel/port(s) 84 // Max Length: 100 85 PpInfo string `json:"pp_info,omitempty"` 86 87 // provider network 88 ProviderNetwork *NestedProviderNetwork `json:"provider_network,omitempty"` 89 90 // site 91 Site *NestedSite `json:"site,omitempty"` 92 93 // Termination 94 // Required: true 95 // Enum: [A Z] 96 TermSide *string `json:"term_side"` 97 98 // Upstream speed (Kbps) 99 // 100 // Upstream speed, if different from port speed 101 // Maximum: 2.147483647e+09 102 // Minimum: 0 103 UpstreamSpeed *int64 `json:"upstream_speed,omitempty"` 104 105 // Url 106 // Read Only: true 107 // Format: uri 108 URL strfmt.URI `json:"url,omitempty"` 109 110 // Cross-connect ID 111 // Max Length: 50 112 XconnectID string `json:"xconnect_id,omitempty"` 113 } 114 115 // Validate validates this circuit termination 116 func (m *CircuitTermination) Validate(formats strfmt.Registry) error { 117 var res []error 118 119 if err := m.validateCable(formats); err != nil { 120 res = append(res, err) 121 } 122 123 if err := m.validateCircuit(formats); err != nil { 124 res = append(res, err) 125 } 126 127 if err := m.validateDescription(formats); err != nil { 128 res = append(res, err) 129 } 130 131 if err := m.validatePortSpeed(formats); err != nil { 132 res = append(res, err) 133 } 134 135 if err := m.validatePpInfo(formats); err != nil { 136 res = append(res, err) 137 } 138 139 if err := m.validateProviderNetwork(formats); err != nil { 140 res = append(res, err) 141 } 142 143 if err := m.validateSite(formats); err != nil { 144 res = append(res, err) 145 } 146 147 if err := m.validateTermSide(formats); err != nil { 148 res = append(res, err) 149 } 150 151 if err := m.validateUpstreamSpeed(formats); err != nil { 152 res = append(res, err) 153 } 154 155 if err := m.validateURL(formats); err != nil { 156 res = append(res, err) 157 } 158 159 if err := m.validateXconnectID(formats); err != nil { 160 res = append(res, err) 161 } 162 163 if len(res) > 0 { 164 return errors.CompositeValidationError(res...) 165 } 166 return nil 167 } 168 169 func (m *CircuitTermination) validateCable(formats strfmt.Registry) error { 170 if swag.IsZero(m.Cable) { // not required 171 return nil 172 } 173 174 if m.Cable != nil { 175 if err := m.Cable.Validate(formats); err != nil { 176 if ve, ok := err.(*errors.Validation); ok { 177 return ve.ValidateName("cable") 178 } else if ce, ok := err.(*errors.CompositeError); ok { 179 return ce.ValidateName("cable") 180 } 181 return err 182 } 183 } 184 185 return nil 186 } 187 188 func (m *CircuitTermination) validateCircuit(formats strfmt.Registry) error { 189 190 if err := validate.Required("circuit", "body", m.Circuit); err != nil { 191 return err 192 } 193 194 if m.Circuit != nil { 195 if err := m.Circuit.Validate(formats); err != nil { 196 if ve, ok := err.(*errors.Validation); ok { 197 return ve.ValidateName("circuit") 198 } else if ce, ok := err.(*errors.CompositeError); ok { 199 return ce.ValidateName("circuit") 200 } 201 return err 202 } 203 } 204 205 return nil 206 } 207 208 func (m *CircuitTermination) validateDescription(formats strfmt.Registry) error { 209 if swag.IsZero(m.Description) { // not required 210 return nil 211 } 212 213 if err := validate.MaxLength("description", "body", m.Description, 200); err != nil { 214 return err 215 } 216 217 return nil 218 } 219 220 func (m *CircuitTermination) validatePortSpeed(formats strfmt.Registry) error { 221 if swag.IsZero(m.PortSpeed) { // not required 222 return nil 223 } 224 225 if err := validate.MinimumInt("port_speed", "body", *m.PortSpeed, 0, false); err != nil { 226 return err 227 } 228 229 if err := validate.MaximumInt("port_speed", "body", *m.PortSpeed, 2.147483647e+09, false); err != nil { 230 return err 231 } 232 233 return nil 234 } 235 236 func (m *CircuitTermination) validatePpInfo(formats strfmt.Registry) error { 237 if swag.IsZero(m.PpInfo) { // not required 238 return nil 239 } 240 241 if err := validate.MaxLength("pp_info", "body", m.PpInfo, 100); err != nil { 242 return err 243 } 244 245 return nil 246 } 247 248 func (m *CircuitTermination) validateProviderNetwork(formats strfmt.Registry) error { 249 if swag.IsZero(m.ProviderNetwork) { // not required 250 return nil 251 } 252 253 if m.ProviderNetwork != nil { 254 if err := m.ProviderNetwork.Validate(formats); err != nil { 255 if ve, ok := err.(*errors.Validation); ok { 256 return ve.ValidateName("provider_network") 257 } else if ce, ok := err.(*errors.CompositeError); ok { 258 return ce.ValidateName("provider_network") 259 } 260 return err 261 } 262 } 263 264 return nil 265 } 266 267 func (m *CircuitTermination) validateSite(formats strfmt.Registry) error { 268 if swag.IsZero(m.Site) { // not required 269 return nil 270 } 271 272 if m.Site != nil { 273 if err := m.Site.Validate(formats); err != nil { 274 if ve, ok := err.(*errors.Validation); ok { 275 return ve.ValidateName("site") 276 } else if ce, ok := err.(*errors.CompositeError); ok { 277 return ce.ValidateName("site") 278 } 279 return err 280 } 281 } 282 283 return nil 284 } 285 286 var circuitTerminationTypeTermSidePropEnum []interface{} 287 288 func init() { 289 var res []string 290 if err := json.Unmarshal([]byte(`["A","Z"]`), &res); err != nil { 291 panic(err) 292 } 293 for _, v := range res { 294 circuitTerminationTypeTermSidePropEnum = append(circuitTerminationTypeTermSidePropEnum, v) 295 } 296 } 297 298 const ( 299 300 // CircuitTerminationTermSideA captures enum value "A" 301 CircuitTerminationTermSideA string = "A" 302 303 // CircuitTerminationTermSideZ captures enum value "Z" 304 CircuitTerminationTermSideZ string = "Z" 305 ) 306 307 // prop value enum 308 func (m *CircuitTermination) validateTermSideEnum(path, location string, value string) error { 309 if err := validate.EnumCase(path, location, value, circuitTerminationTypeTermSidePropEnum, true); err != nil { 310 return err 311 } 312 return nil 313 } 314 315 func (m *CircuitTermination) validateTermSide(formats strfmt.Registry) error { 316 317 if err := validate.Required("term_side", "body", m.TermSide); err != nil { 318 return err 319 } 320 321 // value enum 322 if err := m.validateTermSideEnum("term_side", "body", *m.TermSide); err != nil { 323 return err 324 } 325 326 return nil 327 } 328 329 func (m *CircuitTermination) validateUpstreamSpeed(formats strfmt.Registry) error { 330 if swag.IsZero(m.UpstreamSpeed) { // not required 331 return nil 332 } 333 334 if err := validate.MinimumInt("upstream_speed", "body", *m.UpstreamSpeed, 0, false); err != nil { 335 return err 336 } 337 338 if err := validate.MaximumInt("upstream_speed", "body", *m.UpstreamSpeed, 2.147483647e+09, false); err != nil { 339 return err 340 } 341 342 return nil 343 } 344 345 func (m *CircuitTermination) validateURL(formats strfmt.Registry) error { 346 if swag.IsZero(m.URL) { // not required 347 return nil 348 } 349 350 if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { 351 return err 352 } 353 354 return nil 355 } 356 357 func (m *CircuitTermination) validateXconnectID(formats strfmt.Registry) error { 358 if swag.IsZero(m.XconnectID) { // not required 359 return nil 360 } 361 362 if err := validate.MaxLength("xconnect_id", "body", m.XconnectID, 50); err != nil { 363 return err 364 } 365 366 return nil 367 } 368 369 // ContextValidate validate this circuit termination based on the context it is used 370 func (m *CircuitTermination) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 371 var res []error 372 373 if err := m.contextValidateOccupied(ctx, formats); err != nil { 374 res = append(res, err) 375 } 376 377 if err := m.contextValidateCable(ctx, formats); err != nil { 378 res = append(res, err) 379 } 380 381 if err := m.contextValidateCablePeer(ctx, formats); err != nil { 382 res = append(res, err) 383 } 384 385 if err := m.contextValidateCablePeerType(ctx, formats); err != nil { 386 res = append(res, err) 387 } 388 389 if err := m.contextValidateCircuit(ctx, formats); err != nil { 390 res = append(res, err) 391 } 392 393 if err := m.contextValidateDisplay(ctx, formats); err != nil { 394 res = append(res, err) 395 } 396 397 if err := m.contextValidateID(ctx, formats); err != nil { 398 res = append(res, err) 399 } 400 401 if err := m.contextValidateProviderNetwork(ctx, formats); err != nil { 402 res = append(res, err) 403 } 404 405 if err := m.contextValidateSite(ctx, formats); err != nil { 406 res = append(res, err) 407 } 408 409 if err := m.contextValidateURL(ctx, formats); err != nil { 410 res = append(res, err) 411 } 412 413 if len(res) > 0 { 414 return errors.CompositeValidationError(res...) 415 } 416 return nil 417 } 418 419 func (m *CircuitTermination) contextValidateOccupied(ctx context.Context, formats strfmt.Registry) error { 420 421 if err := validate.ReadOnly(ctx, "_occupied", "body", m.Occupied); err != nil { 422 return err 423 } 424 425 return nil 426 } 427 428 func (m *CircuitTermination) contextValidateCable(ctx context.Context, formats strfmt.Registry) error { 429 430 if m.Cable != nil { 431 if err := m.Cable.ContextValidate(ctx, formats); err != nil { 432 if ve, ok := err.(*errors.Validation); ok { 433 return ve.ValidateName("cable") 434 } else if ce, ok := err.(*errors.CompositeError); ok { 435 return ce.ValidateName("cable") 436 } 437 return err 438 } 439 } 440 441 return nil 442 } 443 444 func (m *CircuitTermination) contextValidateCablePeer(ctx context.Context, formats strfmt.Registry) error { 445 446 return nil 447 } 448 449 func (m *CircuitTermination) contextValidateCablePeerType(ctx context.Context, formats strfmt.Registry) error { 450 451 if err := validate.ReadOnly(ctx, "cable_peer_type", "body", string(m.CablePeerType)); err != nil { 452 return err 453 } 454 455 return nil 456 } 457 458 func (m *CircuitTermination) contextValidateCircuit(ctx context.Context, formats strfmt.Registry) error { 459 460 if m.Circuit != nil { 461 if err := m.Circuit.ContextValidate(ctx, formats); err != nil { 462 if ve, ok := err.(*errors.Validation); ok { 463 return ve.ValidateName("circuit") 464 } else if ce, ok := err.(*errors.CompositeError); ok { 465 return ce.ValidateName("circuit") 466 } 467 return err 468 } 469 } 470 471 return nil 472 } 473 474 func (m *CircuitTermination) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error { 475 476 if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil { 477 return err 478 } 479 480 return nil 481 } 482 483 func (m *CircuitTermination) contextValidateID(ctx context.Context, formats strfmt.Registry) error { 484 485 if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil { 486 return err 487 } 488 489 return nil 490 } 491 492 func (m *CircuitTermination) contextValidateProviderNetwork(ctx context.Context, formats strfmt.Registry) error { 493 494 if m.ProviderNetwork != nil { 495 if err := m.ProviderNetwork.ContextValidate(ctx, formats); err != nil { 496 if ve, ok := err.(*errors.Validation); ok { 497 return ve.ValidateName("provider_network") 498 } else if ce, ok := err.(*errors.CompositeError); ok { 499 return ce.ValidateName("provider_network") 500 } 501 return err 502 } 503 } 504 505 return nil 506 } 507 508 func (m *CircuitTermination) contextValidateSite(ctx context.Context, formats strfmt.Registry) error { 509 510 if m.Site != nil { 511 if err := m.Site.ContextValidate(ctx, formats); err != nil { 512 if ve, ok := err.(*errors.Validation); ok { 513 return ve.ValidateName("site") 514 } else if ce, ok := err.(*errors.CompositeError); ok { 515 return ce.ValidateName("site") 516 } 517 return err 518 } 519 } 520 521 return nil 522 } 523 524 func (m *CircuitTermination) contextValidateURL(ctx context.Context, formats strfmt.Registry) error { 525 526 if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil { 527 return err 528 } 529 530 return nil 531 } 532 533 // MarshalBinary interface implementation 534 func (m *CircuitTermination) MarshalBinary() ([]byte, error) { 535 if m == nil { 536 return nil, nil 537 } 538 return swag.WriteJSON(m) 539 } 540 541 // UnmarshalBinary interface implementation 542 func (m *CircuitTermination) UnmarshalBinary(b []byte) error { 543 var res CircuitTermination 544 if err := swag.ReadJSON(b, &res); err != nil { 545 return err 546 } 547 *m = res 548 return nil 549 }