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 | "encoding/json" |
| 24 | |
| 25 | strfmt "github.com/go-openapi/strfmt" |
| 26 | |
| 27 | "github.com/go-openapi/errors" |
| 28 | "github.com/go-openapi/swag" |
| 29 | "github.com/go-openapi/validate" |
| 30 | ) |
| 31 | |
| 32 | // WritableInterface writable interface |
| 33 | // swagger:model WritableInterface |
| 34 | type WritableInterface struct { |
| 35 | |
| 36 | // Description |
| 37 | // Max Length: 100 |
| 38 | Description string `json:"description,omitempty"` |
| 39 | |
| 40 | // Device |
| 41 | // Required: true |
| 42 | Device *int64 `json:"device"` |
| 43 | |
| 44 | // Enabled |
| 45 | Enabled bool `json:"enabled,omitempty"` |
| 46 | |
| 47 | // Form factor |
| 48 | FormFactor int64 `json:"form_factor,omitempty"` |
| 49 | |
| 50 | // ID |
| 51 | // Read Only: true |
| 52 | ID int64 `json:"id,omitempty"` |
| 53 | |
| 54 | // Parent LAG |
| 55 | Lag int64 `json:"lag,omitempty"` |
| 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 | // Mode |
| 66 | Mode int64 `json:"mode,omitempty"` |
| 67 | |
| 68 | // MTU |
| 69 | // Maximum: 32767 |
| 70 | // Minimum: 0 |
| 71 | Mtu *int64 `json:"mtu,omitempty"` |
| 72 | |
| 73 | // Name |
| 74 | // Required: true |
| 75 | // Max Length: 64 |
| 76 | Name *string `json:"name"` |
| 77 | |
| 78 | // tagged vlans |
| 79 | // Unique: true |
| 80 | TaggedVlans []int64 `json:"tagged_vlans"` |
| 81 | |
| 82 | // Untagged VLAN |
| 83 | UntaggedVlan int64 `json:"untagged_vlan,omitempty"` |
| 84 | } |
| 85 | |
| 86 | // Validate validates this writable interface |
| 87 | func (m *WritableInterface) Validate(formats strfmt.Registry) error { |
| 88 | var res []error |
| 89 | |
| 90 | if err := m.validateDescription(formats); err != nil { |
| 91 | // prop |
| 92 | res = append(res, err) |
| 93 | } |
| 94 | |
| 95 | if err := m.validateDevice(formats); err != nil { |
| 96 | // prop |
| 97 | res = append(res, err) |
| 98 | } |
| 99 | |
| 100 | if err := m.validateFormFactor(formats); err != nil { |
| 101 | // prop |
| 102 | res = append(res, err) |
| 103 | } |
| 104 | |
| 105 | if err := m.validateMode(formats); err != nil { |
| 106 | // prop |
| 107 | res = append(res, err) |
| 108 | } |
| 109 | |
| 110 | if err := m.validateMtu(formats); err != nil { |
| 111 | // prop |
| 112 | res = append(res, err) |
| 113 | } |
| 114 | |
| 115 | if err := m.validateName(formats); err != nil { |
| 116 | // prop |
| 117 | res = append(res, err) |
| 118 | } |
| 119 | |
| 120 | if err := m.validateTaggedVlans(formats); err != nil { |
| 121 | // prop |
| 122 | res = append(res, err) |
| 123 | } |
| 124 | |
| 125 | if len(res) > 0 { |
| 126 | return errors.CompositeValidationError(res...) |
| 127 | } |
| 128 | return nil |
| 129 | } |
| 130 | |
| 131 | func (m *WritableInterface) validateDescription(formats strfmt.Registry) error { |
| 132 | |
| 133 | if swag.IsZero(m.Description) { // not required |
| 134 | return nil |
| 135 | } |
| 136 | |
| 137 | if err := validate.MaxLength("description", "body", string(m.Description), 100); err != nil { |
| 138 | return err |
| 139 | } |
| 140 | |
| 141 | return nil |
| 142 | } |
| 143 | |
| 144 | func (m *WritableInterface) validateDevice(formats strfmt.Registry) error { |
| 145 | |
| 146 | if err := validate.Required("device", "body", m.Device); err != nil { |
| 147 | return err |
| 148 | } |
| 149 | |
| 150 | return nil |
| 151 | } |
| 152 | |
| 153 | var writableInterfaceTypeFormFactorPropEnum []interface{} |
| 154 | |
| 155 | func init() { |
| 156 | var res []int64 |
| 157 | if err := json.Unmarshal([]byte(`[0,200,800,1000,1150,1170,1050,1100,1200,1300,1310,1320,1350,1400,1500,1510,1520,1550,1600,2600,2610,2620,2630,2640,3010,3020,3040,3080,3160,4000,4010,4040,4050,5000,5050,5100,5150,5200,32767]`), &res); err != nil { |
| 158 | panic(err) |
| 159 | } |
| 160 | for _, v := range res { |
| 161 | writableInterfaceTypeFormFactorPropEnum = append(writableInterfaceTypeFormFactorPropEnum, v) |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | // prop value enum |
| 166 | func (m *WritableInterface) validateFormFactorEnum(path, location string, value int64) error { |
| 167 | if err := validate.Enum(path, location, value, writableInterfaceTypeFormFactorPropEnum); err != nil { |
| 168 | return err |
| 169 | } |
| 170 | return nil |
| 171 | } |
| 172 | |
| 173 | func (m *WritableInterface) validateFormFactor(formats strfmt.Registry) error { |
| 174 | |
| 175 | if swag.IsZero(m.FormFactor) { // not required |
| 176 | return nil |
| 177 | } |
| 178 | |
| 179 | // value enum |
| 180 | if err := m.validateFormFactorEnum("form_factor", "body", m.FormFactor); err != nil { |
| 181 | return err |
| 182 | } |
| 183 | |
| 184 | return nil |
| 185 | } |
| 186 | |
| 187 | var writableInterfaceTypeModePropEnum []interface{} |
| 188 | |
| 189 | func init() { |
| 190 | var res []int64 |
| 191 | if err := json.Unmarshal([]byte(`[100,200,300]`), &res); err != nil { |
| 192 | panic(err) |
| 193 | } |
| 194 | for _, v := range res { |
| 195 | writableInterfaceTypeModePropEnum = append(writableInterfaceTypeModePropEnum, v) |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | // prop value enum |
| 200 | func (m *WritableInterface) validateModeEnum(path, location string, value int64) error { |
| 201 | if err := validate.Enum(path, location, value, writableInterfaceTypeModePropEnum); err != nil { |
| 202 | return err |
| 203 | } |
| 204 | return nil |
| 205 | } |
| 206 | |
| 207 | func (m *WritableInterface) validateMode(formats strfmt.Registry) error { |
| 208 | |
| 209 | if swag.IsZero(m.Mode) { // not required |
| 210 | return nil |
| 211 | } |
| 212 | |
| 213 | // value enum |
| 214 | if err := m.validateModeEnum("mode", "body", m.Mode); err != nil { |
| 215 | return err |
| 216 | } |
| 217 | |
| 218 | return nil |
| 219 | } |
| 220 | |
| 221 | func (m *WritableInterface) validateMtu(formats strfmt.Registry) error { |
| 222 | |
| 223 | if swag.IsZero(m.Mtu) { // not required |
| 224 | return nil |
| 225 | } |
| 226 | |
| 227 | if err := validate.MinimumInt("mtu", "body", int64(*m.Mtu), 0, false); err != nil { |
| 228 | return err |
| 229 | } |
| 230 | |
| 231 | if err := validate.MaximumInt("mtu", "body", int64(*m.Mtu), 32767, false); err != nil { |
| 232 | return err |
| 233 | } |
| 234 | |
| 235 | return nil |
| 236 | } |
| 237 | |
| 238 | func (m *WritableInterface) validateName(formats strfmt.Registry) error { |
| 239 | |
| 240 | if err := validate.Required("name", "body", m.Name); err != nil { |
| 241 | return err |
| 242 | } |
| 243 | |
| 244 | if err := validate.MaxLength("name", "body", string(*m.Name), 64); err != nil { |
| 245 | return err |
| 246 | } |
| 247 | |
| 248 | return nil |
| 249 | } |
| 250 | |
| 251 | func (m *WritableInterface) validateTaggedVlans(formats strfmt.Registry) error { |
| 252 | |
| 253 | if swag.IsZero(m.TaggedVlans) { // not required |
| 254 | return nil |
| 255 | } |
| 256 | |
| 257 | if err := validate.UniqueItems("tagged_vlans", "body", m.TaggedVlans); err != nil { |
| 258 | return err |
| 259 | } |
| 260 | |
| 261 | return nil |
| 262 | } |
| 263 | |
| 264 | // MarshalBinary interface implementation |
| 265 | func (m *WritableInterface) MarshalBinary() ([]byte, error) { |
| 266 | if m == nil { |
| 267 | return nil, nil |
| 268 | } |
| 269 | return swag.WriteJSON(m) |
| 270 | } |
| 271 | |
| 272 | // UnmarshalBinary interface implementation |
| 273 | func (m *WritableInterface) UnmarshalBinary(b []byte) error { |
| 274 | var res WritableInterface |
| 275 | if err := swag.ReadJSON(b, &res); err != nil { |
| 276 | return err |
| 277 | } |
| 278 | *m = res |
| 279 | return nil |
| 280 | } |