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 | // PeerInterface Interface a |
| 31 | // swagger:model PeerInterface |
| 32 | type PeerInterface struct { |
| 33 | |
| 34 | // Description |
| 35 | // Max Length: 100 |
| 36 | Description string `json:"description,omitempty"` |
| 37 | |
| 38 | // device |
| 39 | // Required: true |
| 40 | Device *NestedDevice `json:"device"` |
| 41 | |
| 42 | // Enabled |
| 43 | Enabled bool `json:"enabled,omitempty"` |
| 44 | |
| 45 | // form factor |
| 46 | // Required: true |
| 47 | FormFactor *PeerInterfaceFormFactor `json:"form_factor"` |
| 48 | |
| 49 | // ID |
| 50 | // Read Only: true |
| 51 | ID int64 `json:"id,omitempty"` |
| 52 | |
| 53 | // lag |
| 54 | // Required: true |
| 55 | Lag *NestedInterface `json:"lag"` |
| 56 | |
| 57 | // MAC Address |
| 58 | MacAddress string `json:"mac_address,omitempty"` |
| 59 | |
| 60 | // OOB Management |
| 61 | // |
| 62 | // This interface is used only for out-of-band management |
| 63 | MgmtOnly bool `json:"mgmt_only,omitempty"` |
| 64 | |
| 65 | // MTU |
| 66 | // Maximum: 32767 |
| 67 | // Minimum: 0 |
| 68 | Mtu *int64 `json:"mtu,omitempty"` |
| 69 | |
| 70 | // Name |
| 71 | // Required: true |
| 72 | // Max Length: 64 |
| 73 | Name *string `json:"name"` |
| 74 | |
| 75 | // Url |
| 76 | // Read Only: true |
| 77 | URL strfmt.URI `json:"url,omitempty"` |
| 78 | } |
| 79 | |
| 80 | // Validate validates this peer interface |
| 81 | func (m *PeerInterface) Validate(formats strfmt.Registry) error { |
| 82 | var res []error |
| 83 | |
| 84 | if err := m.validateDescription(formats); err != nil { |
| 85 | // prop |
| 86 | res = append(res, err) |
| 87 | } |
| 88 | |
| 89 | if err := m.validateDevice(formats); err != nil { |
| 90 | // prop |
| 91 | res = append(res, err) |
| 92 | } |
| 93 | |
| 94 | if err := m.validateFormFactor(formats); err != nil { |
| 95 | // prop |
| 96 | res = append(res, err) |
| 97 | } |
| 98 | |
| 99 | if err := m.validateLag(formats); err != nil { |
| 100 | // prop |
| 101 | res = append(res, err) |
| 102 | } |
| 103 | |
| 104 | if err := m.validateMtu(formats); err != nil { |
| 105 | // prop |
| 106 | res = append(res, err) |
| 107 | } |
| 108 | |
| 109 | if err := m.validateName(formats); err != nil { |
| 110 | // prop |
| 111 | res = append(res, err) |
| 112 | } |
| 113 | |
| 114 | if len(res) > 0 { |
| 115 | return errors.CompositeValidationError(res...) |
| 116 | } |
| 117 | return nil |
| 118 | } |
| 119 | |
| 120 | func (m *PeerInterface) validateDescription(formats strfmt.Registry) error { |
| 121 | |
| 122 | if swag.IsZero(m.Description) { // not required |
| 123 | return nil |
| 124 | } |
| 125 | |
| 126 | if err := validate.MaxLength("description", "body", string(m.Description), 100); err != nil { |
| 127 | return err |
| 128 | } |
| 129 | |
| 130 | return nil |
| 131 | } |
| 132 | |
| 133 | func (m *PeerInterface) validateDevice(formats strfmt.Registry) error { |
| 134 | |
| 135 | if err := validate.Required("device", "body", m.Device); err != nil { |
| 136 | return err |
| 137 | } |
| 138 | |
| 139 | if m.Device != nil { |
| 140 | |
| 141 | if err := m.Device.Validate(formats); err != nil { |
| 142 | if ve, ok := err.(*errors.Validation); ok { |
| 143 | return ve.ValidateName("device") |
| 144 | } |
| 145 | return err |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | return nil |
| 150 | } |
| 151 | |
| 152 | func (m *PeerInterface) validateFormFactor(formats strfmt.Registry) error { |
| 153 | |
| 154 | if err := validate.Required("form_factor", "body", m.FormFactor); err != nil { |
| 155 | return err |
| 156 | } |
| 157 | |
| 158 | if m.FormFactor != nil { |
| 159 | |
| 160 | if err := m.FormFactor.Validate(formats); err != nil { |
| 161 | if ve, ok := err.(*errors.Validation); ok { |
| 162 | return ve.ValidateName("form_factor") |
| 163 | } |
| 164 | return err |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | return nil |
| 169 | } |
| 170 | |
| 171 | func (m *PeerInterface) validateLag(formats strfmt.Registry) error { |
| 172 | |
| 173 | if err := validate.Required("lag", "body", m.Lag); err != nil { |
| 174 | return err |
| 175 | } |
| 176 | |
| 177 | if m.Lag != nil { |
| 178 | |
| 179 | if err := m.Lag.Validate(formats); err != nil { |
| 180 | if ve, ok := err.(*errors.Validation); ok { |
| 181 | return ve.ValidateName("lag") |
| 182 | } |
| 183 | return err |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | return nil |
| 188 | } |
| 189 | |
| 190 | func (m *PeerInterface) validateMtu(formats strfmt.Registry) error { |
| 191 | |
| 192 | if swag.IsZero(m.Mtu) { // not required |
| 193 | return nil |
| 194 | } |
| 195 | |
| 196 | if err := validate.MinimumInt("mtu", "body", int64(*m.Mtu), 0, false); err != nil { |
| 197 | return err |
| 198 | } |
| 199 | |
| 200 | if err := validate.MaximumInt("mtu", "body", int64(*m.Mtu), 32767, false); err != nil { |
| 201 | return err |
| 202 | } |
| 203 | |
| 204 | return nil |
| 205 | } |
| 206 | |
| 207 | func (m *PeerInterface) validateName(formats strfmt.Registry) error { |
| 208 | |
| 209 | if err := validate.Required("name", "body", m.Name); err != nil { |
| 210 | return err |
| 211 | } |
| 212 | |
| 213 | if err := validate.MaxLength("name", "body", string(*m.Name), 64); err != nil { |
| 214 | return err |
| 215 | } |
| 216 | |
| 217 | return nil |
| 218 | } |
| 219 | |
| 220 | // MarshalBinary interface implementation |
| 221 | func (m *PeerInterface) MarshalBinary() ([]byte, error) { |
| 222 | if m == nil { |
| 223 | return nil, nil |
| 224 | } |
| 225 | return swag.WriteJSON(m) |
| 226 | } |
| 227 | |
| 228 | // UnmarshalBinary interface implementation |
| 229 | func (m *PeerInterface) UnmarshalBinary(b []byte) error { |
| 230 | var res PeerInterface |
| 231 | if err := swag.ReadJSON(b, &res); err != nil { |
| 232 | return err |
| 233 | } |
| 234 | *m = res |
| 235 | return nil |
| 236 | } |