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 | // IPAddress IP address |
| 31 | // swagger:model IPAddress |
| 32 | type IPAddress struct { |
| 33 | |
| 34 | // Address |
| 35 | // |
| 36 | // IPv4 or IPv6 address (with mask) |
| 37 | // Required: true |
| 38 | Address *string `json:"address"` |
| 39 | |
| 40 | // Created |
| 41 | // Read Only: true |
| 42 | Created strfmt.Date `json:"created,omitempty"` |
| 43 | |
| 44 | // Custom fields |
| 45 | CustomFields interface{} `json:"custom_fields,omitempty"` |
| 46 | |
| 47 | // Description |
| 48 | // Max Length: 100 |
| 49 | Description string `json:"description,omitempty"` |
| 50 | |
| 51 | // Family |
| 52 | // Read Only: true |
| 53 | Family int64 `json:"family,omitempty"` |
| 54 | |
| 55 | // ID |
| 56 | // Read Only: true |
| 57 | ID int64 `json:"id,omitempty"` |
| 58 | |
| 59 | // interface |
| 60 | // Required: true |
| 61 | Interface *IPAddressInterface `json:"interface"` |
| 62 | |
| 63 | // Last updated |
| 64 | // Read Only: true |
| 65 | LastUpdated strfmt.DateTime `json:"last_updated,omitempty"` |
| 66 | |
| 67 | // nat inside |
| 68 | // Required: true |
| 69 | NatInside *NestedIPAddress `json:"nat_inside"` |
| 70 | |
| 71 | // nat outside |
| 72 | // Required: true |
| 73 | NatOutside *NestedIPAddress `json:"nat_outside"` |
| 74 | |
| 75 | // role |
| 76 | // Required: true |
| 77 | Role *IPAddressRole `json:"role"` |
| 78 | |
| 79 | // status |
| 80 | // Required: true |
| 81 | Status *IPAddressStatus `json:"status"` |
| 82 | |
| 83 | // tenant |
| 84 | // Required: true |
| 85 | Tenant *NestedTenant `json:"tenant"` |
| 86 | |
| 87 | // vrf |
| 88 | // Required: true |
| 89 | Vrf *NestedVRF `json:"vrf"` |
| 90 | } |
| 91 | |
| 92 | // Validate validates this IP address |
| 93 | func (m *IPAddress) Validate(formats strfmt.Registry) error { |
| 94 | var res []error |
| 95 | |
| 96 | if err := m.validateAddress(formats); err != nil { |
| 97 | // prop |
| 98 | res = append(res, err) |
| 99 | } |
| 100 | |
| 101 | if err := m.validateDescription(formats); err != nil { |
| 102 | // prop |
| 103 | res = append(res, err) |
| 104 | } |
| 105 | |
| 106 | if err := m.validateInterface(formats); err != nil { |
| 107 | // prop |
| 108 | res = append(res, err) |
| 109 | } |
| 110 | |
| 111 | if err := m.validateNatInside(formats); err != nil { |
| 112 | // prop |
| 113 | res = append(res, err) |
| 114 | } |
| 115 | |
| 116 | if err := m.validateNatOutside(formats); err != nil { |
| 117 | // prop |
| 118 | res = append(res, err) |
| 119 | } |
| 120 | |
| 121 | if err := m.validateRole(formats); err != nil { |
| 122 | // prop |
| 123 | res = append(res, err) |
| 124 | } |
| 125 | |
| 126 | if err := m.validateStatus(formats); err != nil { |
| 127 | // prop |
| 128 | res = append(res, err) |
| 129 | } |
| 130 | |
| 131 | if err := m.validateTenant(formats); err != nil { |
| 132 | // prop |
| 133 | res = append(res, err) |
| 134 | } |
| 135 | |
| 136 | if err := m.validateVrf(formats); err != nil { |
| 137 | // prop |
| 138 | res = append(res, err) |
| 139 | } |
| 140 | |
| 141 | if len(res) > 0 { |
| 142 | return errors.CompositeValidationError(res...) |
| 143 | } |
| 144 | return nil |
| 145 | } |
| 146 | |
| 147 | func (m *IPAddress) validateAddress(formats strfmt.Registry) error { |
| 148 | |
| 149 | if err := validate.Required("address", "body", m.Address); err != nil { |
| 150 | return err |
| 151 | } |
| 152 | |
| 153 | return nil |
| 154 | } |
| 155 | |
| 156 | func (m *IPAddress) validateDescription(formats strfmt.Registry) error { |
| 157 | |
| 158 | if swag.IsZero(m.Description) { // not required |
| 159 | return nil |
| 160 | } |
| 161 | |
| 162 | if err := validate.MaxLength("description", "body", string(m.Description), 100); err != nil { |
| 163 | return err |
| 164 | } |
| 165 | |
| 166 | return nil |
| 167 | } |
| 168 | |
| 169 | func (m *IPAddress) validateInterface(formats strfmt.Registry) error { |
| 170 | |
| 171 | if err := validate.Required("interface", "body", m.Interface); err != nil { |
| 172 | return err |
| 173 | } |
| 174 | |
| 175 | if m.Interface != nil { |
| 176 | |
| 177 | if err := m.Interface.Validate(formats); err != nil { |
| 178 | if ve, ok := err.(*errors.Validation); ok { |
| 179 | return ve.ValidateName("interface") |
| 180 | } |
| 181 | return err |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | return nil |
| 186 | } |
| 187 | |
| 188 | func (m *IPAddress) validateNatInside(formats strfmt.Registry) error { |
| 189 | |
| 190 | if err := validate.Required("nat_inside", "body", m.NatInside); err != nil { |
| 191 | return err |
| 192 | } |
| 193 | |
| 194 | if m.NatInside != nil { |
| 195 | |
| 196 | if err := m.NatInside.Validate(formats); err != nil { |
| 197 | if ve, ok := err.(*errors.Validation); ok { |
| 198 | return ve.ValidateName("nat_inside") |
| 199 | } |
| 200 | return err |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | return nil |
| 205 | } |
| 206 | |
| 207 | func (m *IPAddress) validateNatOutside(formats strfmt.Registry) error { |
| 208 | |
| 209 | if err := validate.Required("nat_outside", "body", m.NatOutside); err != nil { |
| 210 | return err |
| 211 | } |
| 212 | |
| 213 | if m.NatOutside != nil { |
| 214 | |
| 215 | if err := m.NatOutside.Validate(formats); err != nil { |
| 216 | if ve, ok := err.(*errors.Validation); ok { |
| 217 | return ve.ValidateName("nat_outside") |
| 218 | } |
| 219 | return err |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | return nil |
| 224 | } |
| 225 | |
| 226 | func (m *IPAddress) validateRole(formats strfmt.Registry) error { |
| 227 | |
| 228 | if err := validate.Required("role", "body", m.Role); err != nil { |
| 229 | return err |
| 230 | } |
| 231 | |
| 232 | if m.Role != nil { |
| 233 | |
| 234 | if err := m.Role.Validate(formats); err != nil { |
| 235 | if ve, ok := err.(*errors.Validation); ok { |
| 236 | return ve.ValidateName("role") |
| 237 | } |
| 238 | return err |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | return nil |
| 243 | } |
| 244 | |
| 245 | func (m *IPAddress) validateStatus(formats strfmt.Registry) error { |
| 246 | |
| 247 | if err := validate.Required("status", "body", m.Status); err != nil { |
| 248 | return err |
| 249 | } |
| 250 | |
| 251 | if m.Status != nil { |
| 252 | |
| 253 | if err := m.Status.Validate(formats); err != nil { |
| 254 | if ve, ok := err.(*errors.Validation); ok { |
| 255 | return ve.ValidateName("status") |
| 256 | } |
| 257 | return err |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | return nil |
| 262 | } |
| 263 | |
| 264 | func (m *IPAddress) validateTenant(formats strfmt.Registry) error { |
| 265 | |
| 266 | if err := validate.Required("tenant", "body", m.Tenant); err != nil { |
| 267 | return err |
| 268 | } |
| 269 | |
| 270 | if m.Tenant != nil { |
| 271 | |
| 272 | if err := m.Tenant.Validate(formats); err != nil { |
| 273 | if ve, ok := err.(*errors.Validation); ok { |
| 274 | return ve.ValidateName("tenant") |
| 275 | } |
| 276 | return err |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | return nil |
| 281 | } |
| 282 | |
| 283 | func (m *IPAddress) validateVrf(formats strfmt.Registry) error { |
| 284 | |
| 285 | if err := validate.Required("vrf", "body", m.Vrf); err != nil { |
| 286 | return err |
| 287 | } |
| 288 | |
| 289 | if m.Vrf != nil { |
| 290 | |
| 291 | if err := m.Vrf.Validate(formats); err != nil { |
| 292 | if ve, ok := err.(*errors.Validation); ok { |
| 293 | return ve.ValidateName("vrf") |
| 294 | } |
| 295 | return err |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | return nil |
| 300 | } |
| 301 | |
| 302 | // MarshalBinary interface implementation |
| 303 | func (m *IPAddress) MarshalBinary() ([]byte, error) { |
| 304 | if m == nil { |
| 305 | return nil, nil |
| 306 | } |
| 307 | return swag.WriteJSON(m) |
| 308 | } |
| 309 | |
| 310 | // UnmarshalBinary interface implementation |
| 311 | func (m *IPAddress) UnmarshalBinary(b []byte) error { |
| 312 | var res IPAddress |
| 313 | if err := swag.ReadJSON(b, &res); err != nil { |
| 314 | return err |
| 315 | } |
| 316 | *m = res |
| 317 | return nil |
| 318 | } |