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 | // Rack rack |
| 31 | // swagger:model Rack |
| 32 | type Rack struct { |
| 33 | |
| 34 | // Comments |
| 35 | Comments string `json:"comments,omitempty"` |
| 36 | |
| 37 | // Created |
| 38 | // Read Only: true |
| 39 | Created strfmt.Date `json:"created,omitempty"` |
| 40 | |
| 41 | // Custom fields |
| 42 | CustomFields interface{} `json:"custom_fields,omitempty"` |
| 43 | |
| 44 | // Descending units |
| 45 | // |
| 46 | // Units are numbered top-to-bottom |
| 47 | DescUnits bool `json:"desc_units,omitempty"` |
| 48 | |
| 49 | // Display name |
| 50 | // Read Only: true |
| 51 | DisplayName string `json:"display_name,omitempty"` |
| 52 | |
| 53 | // Facility ID |
| 54 | // Required: true |
| 55 | // Max Length: 50 |
| 56 | FacilityID *string `json:"facility_id"` |
| 57 | |
| 58 | // group |
| 59 | // Required: true |
| 60 | Group *NestedRackGroup `json:"group"` |
| 61 | |
| 62 | // ID |
| 63 | // Read Only: true |
| 64 | ID int64 `json:"id,omitempty"` |
| 65 | |
| 66 | // Last updated |
| 67 | // Read Only: true |
| 68 | LastUpdated strfmt.DateTime `json:"last_updated,omitempty"` |
| 69 | |
| 70 | // Name |
| 71 | // Required: true |
| 72 | // Max Length: 50 |
| 73 | Name *string `json:"name"` |
| 74 | |
| 75 | // role |
| 76 | // Required: true |
| 77 | Role *NestedRackRole `json:"role"` |
| 78 | |
| 79 | // Serial number |
| 80 | // Max Length: 50 |
| 81 | Serial string `json:"serial,omitempty"` |
| 82 | |
| 83 | // site |
| 84 | // Required: true |
| 85 | Site *NestedSite `json:"site"` |
| 86 | |
| 87 | // tenant |
| 88 | // Required: true |
| 89 | Tenant *NestedTenant `json:"tenant"` |
| 90 | |
| 91 | // type |
| 92 | // Required: true |
| 93 | Type *RackType `json:"type"` |
| 94 | |
| 95 | // Height (U) |
| 96 | // Maximum: 100 |
| 97 | // Minimum: 1 |
| 98 | UHeight int64 `json:"u_height,omitempty"` |
| 99 | |
| 100 | // width |
| 101 | // Required: true |
| 102 | Width *RackWidth `json:"width"` |
| 103 | } |
| 104 | |
| 105 | // Validate validates this rack |
| 106 | func (m *Rack) Validate(formats strfmt.Registry) error { |
| 107 | var res []error |
| 108 | |
| 109 | if err := m.validateFacilityID(formats); err != nil { |
| 110 | // prop |
| 111 | res = append(res, err) |
| 112 | } |
| 113 | |
| 114 | if err := m.validateGroup(formats); err != nil { |
| 115 | // prop |
| 116 | res = append(res, err) |
| 117 | } |
| 118 | |
| 119 | if err := m.validateName(formats); err != nil { |
| 120 | // prop |
| 121 | res = append(res, err) |
| 122 | } |
| 123 | |
| 124 | if err := m.validateRole(formats); err != nil { |
| 125 | // prop |
| 126 | res = append(res, err) |
| 127 | } |
| 128 | |
| 129 | if err := m.validateSerial(formats); err != nil { |
| 130 | // prop |
| 131 | res = append(res, err) |
| 132 | } |
| 133 | |
| 134 | if err := m.validateSite(formats); err != nil { |
| 135 | // prop |
| 136 | res = append(res, err) |
| 137 | } |
| 138 | |
| 139 | if err := m.validateTenant(formats); err != nil { |
| 140 | // prop |
| 141 | res = append(res, err) |
| 142 | } |
| 143 | |
| 144 | if err := m.validateType(formats); err != nil { |
| 145 | // prop |
| 146 | res = append(res, err) |
| 147 | } |
| 148 | |
| 149 | if err := m.validateUHeight(formats); err != nil { |
| 150 | // prop |
| 151 | res = append(res, err) |
| 152 | } |
| 153 | |
| 154 | if err := m.validateWidth(formats); err != nil { |
| 155 | // prop |
| 156 | res = append(res, err) |
| 157 | } |
| 158 | |
| 159 | if len(res) > 0 { |
| 160 | return errors.CompositeValidationError(res...) |
| 161 | } |
| 162 | return nil |
| 163 | } |
| 164 | |
| 165 | func (m *Rack) validateFacilityID(formats strfmt.Registry) error { |
| 166 | |
| 167 | if err := validate.Required("facility_id", "body", m.FacilityID); err != nil { |
| 168 | return err |
| 169 | } |
| 170 | |
| 171 | if err := validate.MaxLength("facility_id", "body", string(*m.FacilityID), 50); err != nil { |
| 172 | return err |
| 173 | } |
| 174 | |
| 175 | return nil |
| 176 | } |
| 177 | |
| 178 | func (m *Rack) validateGroup(formats strfmt.Registry) error { |
| 179 | |
| 180 | if err := validate.Required("group", "body", m.Group); err != nil { |
| 181 | return err |
| 182 | } |
| 183 | |
| 184 | if m.Group != nil { |
| 185 | |
| 186 | if err := m.Group.Validate(formats); err != nil { |
| 187 | if ve, ok := err.(*errors.Validation); ok { |
| 188 | return ve.ValidateName("group") |
| 189 | } |
| 190 | return err |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | return nil |
| 195 | } |
| 196 | |
| 197 | func (m *Rack) validateName(formats strfmt.Registry) error { |
| 198 | |
| 199 | if err := validate.Required("name", "body", m.Name); err != nil { |
| 200 | return err |
| 201 | } |
| 202 | |
| 203 | if err := validate.MaxLength("name", "body", string(*m.Name), 50); err != nil { |
| 204 | return err |
| 205 | } |
| 206 | |
| 207 | return nil |
| 208 | } |
| 209 | |
| 210 | func (m *Rack) validateRole(formats strfmt.Registry) error { |
| 211 | |
| 212 | if err := validate.Required("role", "body", m.Role); err != nil { |
| 213 | return err |
| 214 | } |
| 215 | |
| 216 | if m.Role != nil { |
| 217 | |
| 218 | if err := m.Role.Validate(formats); err != nil { |
| 219 | if ve, ok := err.(*errors.Validation); ok { |
| 220 | return ve.ValidateName("role") |
| 221 | } |
| 222 | return err |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | return nil |
| 227 | } |
| 228 | |
| 229 | func (m *Rack) validateSerial(formats strfmt.Registry) error { |
| 230 | |
| 231 | if swag.IsZero(m.Serial) { // not required |
| 232 | return nil |
| 233 | } |
| 234 | |
| 235 | if err := validate.MaxLength("serial", "body", string(m.Serial), 50); err != nil { |
| 236 | return err |
| 237 | } |
| 238 | |
| 239 | return nil |
| 240 | } |
| 241 | |
| 242 | func (m *Rack) validateSite(formats strfmt.Registry) error { |
| 243 | |
| 244 | if err := validate.Required("site", "body", m.Site); err != nil { |
| 245 | return err |
| 246 | } |
| 247 | |
| 248 | if m.Site != nil { |
| 249 | |
| 250 | if err := m.Site.Validate(formats); err != nil { |
| 251 | if ve, ok := err.(*errors.Validation); ok { |
| 252 | return ve.ValidateName("site") |
| 253 | } |
| 254 | return err |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | return nil |
| 259 | } |
| 260 | |
| 261 | func (m *Rack) validateTenant(formats strfmt.Registry) error { |
| 262 | |
| 263 | if err := validate.Required("tenant", "body", m.Tenant); err != nil { |
| 264 | return err |
| 265 | } |
| 266 | |
| 267 | if m.Tenant != nil { |
| 268 | |
| 269 | if err := m.Tenant.Validate(formats); err != nil { |
| 270 | if ve, ok := err.(*errors.Validation); ok { |
| 271 | return ve.ValidateName("tenant") |
| 272 | } |
| 273 | return err |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | return nil |
| 278 | } |
| 279 | |
| 280 | func (m *Rack) validateType(formats strfmt.Registry) error { |
| 281 | |
| 282 | if err := validate.Required("type", "body", m.Type); err != nil { |
| 283 | return err |
| 284 | } |
| 285 | |
| 286 | if m.Type != nil { |
| 287 | |
| 288 | if err := m.Type.Validate(formats); err != nil { |
| 289 | if ve, ok := err.(*errors.Validation); ok { |
| 290 | return ve.ValidateName("type") |
| 291 | } |
| 292 | return err |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | return nil |
| 297 | } |
| 298 | |
| 299 | func (m *Rack) validateUHeight(formats strfmt.Registry) error { |
| 300 | |
| 301 | if swag.IsZero(m.UHeight) { // not required |
| 302 | return nil |
| 303 | } |
| 304 | |
| 305 | if err := validate.MinimumInt("u_height", "body", int64(m.UHeight), 1, false); err != nil { |
| 306 | return err |
| 307 | } |
| 308 | |
| 309 | if err := validate.MaximumInt("u_height", "body", int64(m.UHeight), 100, false); err != nil { |
| 310 | return err |
| 311 | } |
| 312 | |
| 313 | return nil |
| 314 | } |
| 315 | |
| 316 | func (m *Rack) validateWidth(formats strfmt.Registry) error { |
| 317 | |
| 318 | if err := validate.Required("width", "body", m.Width); err != nil { |
| 319 | return err |
| 320 | } |
| 321 | |
| 322 | if m.Width != nil { |
| 323 | |
| 324 | if err := m.Width.Validate(formats); err != nil { |
| 325 | if ve, ok := err.(*errors.Validation); ok { |
| 326 | return ve.ValidateName("width") |
| 327 | } |
| 328 | return err |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | return nil |
| 333 | } |
| 334 | |
| 335 | // MarshalBinary interface implementation |
| 336 | func (m *Rack) MarshalBinary() ([]byte, error) { |
| 337 | if m == nil { |
| 338 | return nil, nil |
| 339 | } |
| 340 | return swag.WriteJSON(m) |
| 341 | } |
| 342 | |
| 343 | // UnmarshalBinary interface implementation |
| 344 | func (m *Rack) UnmarshalBinary(b []byte) error { |
| 345 | var res Rack |
| 346 | if err := swag.ReadJSON(b, &res); err != nil { |
| 347 | return err |
| 348 | } |
| 349 | *m = res |
| 350 | return nil |
| 351 | } |