Serge Bazanski | cc25bdf | 2018-10-25 14:02:58 +0200 | [diff] [blame] | 1 | // Code generated by go-swagger; DO NOT EDIT. |
| 2 | |
| 3 | // Copyright 2018 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 | package models |
| 18 | |
| 19 | // This file was generated by the swagger tool. |
| 20 | // Editing this file might prove futile when you re-run the swagger generate command |
| 21 | |
| 22 | import ( |
| 23 | strfmt "github.com/go-openapi/strfmt" |
| 24 | |
| 25 | "github.com/go-openapi/errors" |
| 26 | "github.com/go-openapi/swag" |
| 27 | "github.com/go-openapi/validate" |
| 28 | ) |
| 29 | |
| 30 | // Interface Interface |
| 31 | // swagger:model Interface |
| 32 | type Interface struct { |
| 33 | |
| 34 | // circuit termination |
| 35 | // Required: true |
| 36 | CircuitTermination *InterfaceCircuitTermination `json:"circuit_termination"` |
| 37 | |
| 38 | // Description |
| 39 | // Max Length: 100 |
| 40 | Description string `json:"description,omitempty"` |
| 41 | |
| 42 | // device |
| 43 | // Required: true |
| 44 | Device *NestedDevice `json:"device"` |
| 45 | |
| 46 | // Enabled |
| 47 | Enabled bool `json:"enabled,omitempty"` |
| 48 | |
| 49 | // form factor |
| 50 | // Required: true |
| 51 | FormFactor *InterfaceFormFactor `json:"form_factor"` |
| 52 | |
| 53 | // ID |
| 54 | // Read Only: true |
| 55 | ID int64 `json:"id,omitempty"` |
| 56 | |
| 57 | // Interface connection |
| 58 | // Read Only: true |
| 59 | InterfaceConnection string `json:"interface_connection,omitempty"` |
| 60 | |
| 61 | // Is connected |
| 62 | // Read Only: true |
| 63 | IsConnected string `json:"is_connected,omitempty"` |
| 64 | |
| 65 | // lag |
| 66 | // Required: true |
| 67 | Lag *NestedInterface `json:"lag"` |
| 68 | |
| 69 | // MAC Address |
| 70 | MacAddress string `json:"mac_address,omitempty"` |
| 71 | |
| 72 | // OOB Management |
| 73 | // |
| 74 | // This interface is used only for out-of-band management |
| 75 | MgmtOnly bool `json:"mgmt_only,omitempty"` |
| 76 | |
| 77 | // mode |
| 78 | // Required: true |
| 79 | Mode *InterfaceMode `json:"mode"` |
| 80 | |
| 81 | // MTU |
| 82 | // Maximum: 32767 |
| 83 | // Minimum: 0 |
| 84 | Mtu *int64 `json:"mtu,omitempty"` |
| 85 | |
| 86 | // Name |
| 87 | // Required: true |
| 88 | // Max Length: 64 |
| 89 | Name *string `json:"name"` |
| 90 | |
| 91 | // tagged vlans |
| 92 | // Required: true |
| 93 | TaggedVlans InterfaceTaggedVlans `json:"tagged_vlans"` |
| 94 | |
| 95 | // untagged vlan |
| 96 | // Required: true |
| 97 | UntaggedVlan *InterfaceVLAN `json:"untagged_vlan"` |
| 98 | } |
| 99 | |
| 100 | // Validate validates this interface |
| 101 | func (m *Interface) Validate(formats strfmt.Registry) error { |
| 102 | var res []error |
| 103 | |
| 104 | if err := m.validateCircuitTermination(formats); err != nil { |
| 105 | // prop |
| 106 | res = append(res, err) |
| 107 | } |
| 108 | |
| 109 | if err := m.validateDescription(formats); err != nil { |
| 110 | // prop |
| 111 | res = append(res, err) |
| 112 | } |
| 113 | |
| 114 | if err := m.validateDevice(formats); err != nil { |
| 115 | // prop |
| 116 | res = append(res, err) |
| 117 | } |
| 118 | |
| 119 | if err := m.validateFormFactor(formats); err != nil { |
| 120 | // prop |
| 121 | res = append(res, err) |
| 122 | } |
| 123 | |
| 124 | if err := m.validateLag(formats); err != nil { |
| 125 | // prop |
| 126 | res = append(res, err) |
| 127 | } |
| 128 | |
| 129 | if err := m.validateMode(formats); err != nil { |
| 130 | // prop |
| 131 | res = append(res, err) |
| 132 | } |
| 133 | |
| 134 | if err := m.validateMtu(formats); err != nil { |
| 135 | // prop |
| 136 | res = append(res, err) |
| 137 | } |
| 138 | |
| 139 | if err := m.validateName(formats); err != nil { |
| 140 | // prop |
| 141 | res = append(res, err) |
| 142 | } |
| 143 | |
| 144 | if err := m.validateTaggedVlans(formats); err != nil { |
| 145 | // prop |
| 146 | res = append(res, err) |
| 147 | } |
| 148 | |
| 149 | if err := m.validateUntaggedVlan(formats); err != nil { |
| 150 | // prop |
| 151 | res = append(res, err) |
| 152 | } |
| 153 | |
| 154 | if len(res) > 0 { |
| 155 | return errors.CompositeValidationError(res...) |
| 156 | } |
| 157 | return nil |
| 158 | } |
| 159 | |
| 160 | func (m *Interface) validateCircuitTermination(formats strfmt.Registry) error { |
| 161 | |
| 162 | if err := validate.Required("circuit_termination", "body", m.CircuitTermination); err != nil { |
| 163 | return err |
| 164 | } |
| 165 | |
| 166 | if m.CircuitTermination != nil { |
| 167 | |
| 168 | if err := m.CircuitTermination.Validate(formats); err != nil { |
| 169 | if ve, ok := err.(*errors.Validation); ok { |
| 170 | return ve.ValidateName("circuit_termination") |
| 171 | } |
| 172 | return err |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | return nil |
| 177 | } |
| 178 | |
| 179 | func (m *Interface) validateDescription(formats strfmt.Registry) error { |
| 180 | |
| 181 | if swag.IsZero(m.Description) { // not required |
| 182 | return nil |
| 183 | } |
| 184 | |
| 185 | if err := validate.MaxLength("description", "body", string(m.Description), 100); err != nil { |
| 186 | return err |
| 187 | } |
| 188 | |
| 189 | return nil |
| 190 | } |
| 191 | |
| 192 | func (m *Interface) validateDevice(formats strfmt.Registry) error { |
| 193 | |
| 194 | if err := validate.Required("device", "body", m.Device); err != nil { |
| 195 | return err |
| 196 | } |
| 197 | |
| 198 | if m.Device != nil { |
| 199 | |
| 200 | if err := m.Device.Validate(formats); err != nil { |
| 201 | if ve, ok := err.(*errors.Validation); ok { |
| 202 | return ve.ValidateName("device") |
| 203 | } |
| 204 | return err |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | return nil |
| 209 | } |
| 210 | |
| 211 | func (m *Interface) validateFormFactor(formats strfmt.Registry) error { |
| 212 | |
| 213 | if err := validate.Required("form_factor", "body", m.FormFactor); err != nil { |
| 214 | return err |
| 215 | } |
| 216 | |
| 217 | if m.FormFactor != nil { |
| 218 | |
| 219 | if err := m.FormFactor.Validate(formats); err != nil { |
| 220 | if ve, ok := err.(*errors.Validation); ok { |
| 221 | return ve.ValidateName("form_factor") |
| 222 | } |
| 223 | return err |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | return nil |
| 228 | } |
| 229 | |
| 230 | func (m *Interface) validateLag(formats strfmt.Registry) error { |
| 231 | |
| 232 | if err := validate.Required("lag", "body", m.Lag); err != nil { |
| 233 | return err |
| 234 | } |
| 235 | |
| 236 | if m.Lag != nil { |
| 237 | |
| 238 | if err := m.Lag.Validate(formats); err != nil { |
| 239 | if ve, ok := err.(*errors.Validation); ok { |
| 240 | return ve.ValidateName("lag") |
| 241 | } |
| 242 | return err |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | return nil |
| 247 | } |
| 248 | |
| 249 | func (m *Interface) validateMode(formats strfmt.Registry) error { |
| 250 | |
| 251 | if err := validate.Required("mode", "body", m.Mode); err != nil { |
| 252 | return err |
| 253 | } |
| 254 | |
| 255 | if m.Mode != nil { |
| 256 | |
| 257 | if err := m.Mode.Validate(formats); err != nil { |
| 258 | if ve, ok := err.(*errors.Validation); ok { |
| 259 | return ve.ValidateName("mode") |
| 260 | } |
| 261 | return err |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | return nil |
| 266 | } |
| 267 | |
| 268 | func (m *Interface) validateMtu(formats strfmt.Registry) error { |
| 269 | |
| 270 | if swag.IsZero(m.Mtu) { // not required |
| 271 | return nil |
| 272 | } |
| 273 | |
| 274 | if err := validate.MinimumInt("mtu", "body", int64(*m.Mtu), 0, false); err != nil { |
| 275 | return err |
| 276 | } |
| 277 | |
| 278 | if err := validate.MaximumInt("mtu", "body", int64(*m.Mtu), 32767, false); err != nil { |
| 279 | return err |
| 280 | } |
| 281 | |
| 282 | return nil |
| 283 | } |
| 284 | |
| 285 | func (m *Interface) validateName(formats strfmt.Registry) error { |
| 286 | |
| 287 | if err := validate.Required("name", "body", m.Name); err != nil { |
| 288 | return err |
| 289 | } |
| 290 | |
| 291 | if err := validate.MaxLength("name", "body", string(*m.Name), 64); err != nil { |
| 292 | return err |
| 293 | } |
| 294 | |
| 295 | return nil |
| 296 | } |
| 297 | |
| 298 | func (m *Interface) validateTaggedVlans(formats strfmt.Registry) error { |
| 299 | |
| 300 | if err := validate.Required("tagged_vlans", "body", m.TaggedVlans); err != nil { |
| 301 | return err |
| 302 | } |
| 303 | |
| 304 | if err := m.TaggedVlans.Validate(formats); err != nil { |
| 305 | if ve, ok := err.(*errors.Validation); ok { |
| 306 | return ve.ValidateName("tagged_vlans") |
| 307 | } |
| 308 | return err |
| 309 | } |
| 310 | |
| 311 | return nil |
| 312 | } |
| 313 | |
| 314 | func (m *Interface) validateUntaggedVlan(formats strfmt.Registry) error { |
| 315 | |
| 316 | if err := validate.Required("untagged_vlan", "body", m.UntaggedVlan); err != nil { |
| 317 | return err |
| 318 | } |
| 319 | |
| 320 | if m.UntaggedVlan != nil { |
| 321 | |
| 322 | if err := m.UntaggedVlan.Validate(formats); err != nil { |
| 323 | if ve, ok := err.(*errors.Validation); ok { |
| 324 | return ve.ValidateName("untagged_vlan") |
| 325 | } |
| 326 | return err |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | return nil |
| 331 | } |
| 332 | |
| 333 | // MarshalBinary interface implementation |
| 334 | func (m *Interface) MarshalBinary() ([]byte, error) { |
| 335 | if m == nil { |
| 336 | return nil, nil |
| 337 | } |
| 338 | return swag.WriteJSON(m) |
| 339 | } |
| 340 | |
| 341 | // UnmarshalBinary interface implementation |
| 342 | func (m *Interface) UnmarshalBinary(b []byte) error { |
| 343 | var res Interface |
| 344 | if err := swag.ReadJSON(b, &res); err != nil { |
| 345 | return err |
| 346 | } |
| 347 | *m = res |
| 348 | return nil |
| 349 | } |