github.com/digitalocean/go-netbox@v0.0.2/netbox/models/writable_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 // WritableCircuitTermination writable circuit termination 34 // 35 // swagger:model WritableCircuitTermination 36 type WritableCircuitTermination 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 *int64 `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 *int64 `json:"provider_network,omitempty"` 89 90 // Site 91 Site *int64 `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 writable circuit termination 116 func (m *WritableCircuitTermination) 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.validateTermSide(formats); err != nil { 140 res = append(res, err) 141 } 142 143 if err := m.validateUpstreamSpeed(formats); err != nil { 144 res = append(res, err) 145 } 146 147 if err := m.validateURL(formats); err != nil { 148 res = append(res, err) 149 } 150 151 if err := m.validateXconnectID(formats); err != nil { 152 res = append(res, err) 153 } 154 155 if len(res) > 0 { 156 return errors.CompositeValidationError(res...) 157 } 158 return nil 159 } 160 161 func (m *WritableCircuitTermination) validateCable(formats strfmt.Registry) error { 162 if swag.IsZero(m.Cable) { // not required 163 return nil 164 } 165 166 if m.Cable != nil { 167 if err := m.Cable.Validate(formats); err != nil { 168 if ve, ok := err.(*errors.Validation); ok { 169 return ve.ValidateName("cable") 170 } else if ce, ok := err.(*errors.CompositeError); ok { 171 return ce.ValidateName("cable") 172 } 173 return err 174 } 175 } 176 177 return nil 178 } 179 180 func (m *WritableCircuitTermination) validateCircuit(formats strfmt.Registry) error { 181 182 if err := validate.Required("circuit", "body", m.Circuit); err != nil { 183 return err 184 } 185 186 return nil 187 } 188 189 func (m *WritableCircuitTermination) validateDescription(formats strfmt.Registry) error { 190 if swag.IsZero(m.Description) { // not required 191 return nil 192 } 193 194 if err := validate.MaxLength("description", "body", m.Description, 200); err != nil { 195 return err 196 } 197 198 return nil 199 } 200 201 func (m *WritableCircuitTermination) validatePortSpeed(formats strfmt.Registry) error { 202 if swag.IsZero(m.PortSpeed) { // not required 203 return nil 204 } 205 206 if err := validate.MinimumInt("port_speed", "body", *m.PortSpeed, 0, false); err != nil { 207 return err 208 } 209 210 if err := validate.MaximumInt("port_speed", "body", *m.PortSpeed, 2.147483647e+09, false); err != nil { 211 return err 212 } 213 214 return nil 215 } 216 217 func (m *WritableCircuitTermination) validatePpInfo(formats strfmt.Registry) error { 218 if swag.IsZero(m.PpInfo) { // not required 219 return nil 220 } 221 222 if err := validate.MaxLength("pp_info", "body", m.PpInfo, 100); err != nil { 223 return err 224 } 225 226 return nil 227 } 228 229 var writableCircuitTerminationTypeTermSidePropEnum []interface{} 230 231 func init() { 232 var res []string 233 if err := json.Unmarshal([]byte(`["A","Z"]`), &res); err != nil { 234 panic(err) 235 } 236 for _, v := range res { 237 writableCircuitTerminationTypeTermSidePropEnum = append(writableCircuitTerminationTypeTermSidePropEnum, v) 238 } 239 } 240 241 const ( 242 243 // WritableCircuitTerminationTermSideA captures enum value "A" 244 WritableCircuitTerminationTermSideA string = "A" 245 246 // WritableCircuitTerminationTermSideZ captures enum value "Z" 247 WritableCircuitTerminationTermSideZ string = "Z" 248 ) 249 250 // prop value enum 251 func (m *WritableCircuitTermination) validateTermSideEnum(path, location string, value string) error { 252 if err := validate.EnumCase(path, location, value, writableCircuitTerminationTypeTermSidePropEnum, true); err != nil { 253 return err 254 } 255 return nil 256 } 257 258 func (m *WritableCircuitTermination) validateTermSide(formats strfmt.Registry) error { 259 260 if err := validate.Required("term_side", "body", m.TermSide); err != nil { 261 return err 262 } 263 264 // value enum 265 if err := m.validateTermSideEnum("term_side", "body", *m.TermSide); err != nil { 266 return err 267 } 268 269 return nil 270 } 271 272 func (m *WritableCircuitTermination) validateUpstreamSpeed(formats strfmt.Registry) error { 273 if swag.IsZero(m.UpstreamSpeed) { // not required 274 return nil 275 } 276 277 if err := validate.MinimumInt("upstream_speed", "body", *m.UpstreamSpeed, 0, false); err != nil { 278 return err 279 } 280 281 if err := validate.MaximumInt("upstream_speed", "body", *m.UpstreamSpeed, 2.147483647e+09, false); err != nil { 282 return err 283 } 284 285 return nil 286 } 287 288 func (m *WritableCircuitTermination) validateURL(formats strfmt.Registry) error { 289 if swag.IsZero(m.URL) { // not required 290 return nil 291 } 292 293 if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { 294 return err 295 } 296 297 return nil 298 } 299 300 func (m *WritableCircuitTermination) validateXconnectID(formats strfmt.Registry) error { 301 if swag.IsZero(m.XconnectID) { // not required 302 return nil 303 } 304 305 if err := validate.MaxLength("xconnect_id", "body", m.XconnectID, 50); err != nil { 306 return err 307 } 308 309 return nil 310 } 311 312 // ContextValidate validate this writable circuit termination based on the context it is used 313 func (m *WritableCircuitTermination) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 314 var res []error 315 316 if err := m.contextValidateOccupied(ctx, formats); err != nil { 317 res = append(res, err) 318 } 319 320 if err := m.contextValidateCable(ctx, formats); err != nil { 321 res = append(res, err) 322 } 323 324 if err := m.contextValidateCablePeer(ctx, formats); err != nil { 325 res = append(res, err) 326 } 327 328 if err := m.contextValidateCablePeerType(ctx, formats); err != nil { 329 res = append(res, err) 330 } 331 332 if err := m.contextValidateDisplay(ctx, formats); err != nil { 333 res = append(res, err) 334 } 335 336 if err := m.contextValidateID(ctx, formats); err != nil { 337 res = append(res, err) 338 } 339 340 if err := m.contextValidateURL(ctx, formats); err != nil { 341 res = append(res, err) 342 } 343 344 if len(res) > 0 { 345 return errors.CompositeValidationError(res...) 346 } 347 return nil 348 } 349 350 func (m *WritableCircuitTermination) contextValidateOccupied(ctx context.Context, formats strfmt.Registry) error { 351 352 if err := validate.ReadOnly(ctx, "_occupied", "body", m.Occupied); err != nil { 353 return err 354 } 355 356 return nil 357 } 358 359 func (m *WritableCircuitTermination) contextValidateCable(ctx context.Context, formats strfmt.Registry) error { 360 361 if m.Cable != nil { 362 if err := m.Cable.ContextValidate(ctx, formats); err != nil { 363 if ve, ok := err.(*errors.Validation); ok { 364 return ve.ValidateName("cable") 365 } else if ce, ok := err.(*errors.CompositeError); ok { 366 return ce.ValidateName("cable") 367 } 368 return err 369 } 370 } 371 372 return nil 373 } 374 375 func (m *WritableCircuitTermination) contextValidateCablePeer(ctx context.Context, formats strfmt.Registry) error { 376 377 return nil 378 } 379 380 func (m *WritableCircuitTermination) contextValidateCablePeerType(ctx context.Context, formats strfmt.Registry) error { 381 382 if err := validate.ReadOnly(ctx, "cable_peer_type", "body", string(m.CablePeerType)); err != nil { 383 return err 384 } 385 386 return nil 387 } 388 389 func (m *WritableCircuitTermination) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error { 390 391 if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil { 392 return err 393 } 394 395 return nil 396 } 397 398 func (m *WritableCircuitTermination) contextValidateID(ctx context.Context, formats strfmt.Registry) error { 399 400 if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil { 401 return err 402 } 403 404 return nil 405 } 406 407 func (m *WritableCircuitTermination) contextValidateURL(ctx context.Context, formats strfmt.Registry) error { 408 409 if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil { 410 return err 411 } 412 413 return nil 414 } 415 416 // MarshalBinary interface implementation 417 func (m *WritableCircuitTermination) MarshalBinary() ([]byte, error) { 418 if m == nil { 419 return nil, nil 420 } 421 return swag.WriteJSON(m) 422 } 423 424 // UnmarshalBinary interface implementation 425 func (m *WritableCircuitTermination) UnmarshalBinary(b []byte) error { 426 var res WritableCircuitTermination 427 if err := swag.ReadJSON(b, &res); err != nil { 428 return err 429 } 430 *m = res 431 return nil 432 }