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 | // VirtualMachine virtual machine |
| 31 | // swagger:model VirtualMachine |
| 32 | type VirtualMachine struct { |
| 33 | |
| 34 | // cluster |
| 35 | // Required: true |
| 36 | Cluster *NestedCluster `json:"cluster"` |
| 37 | |
| 38 | // Comments |
| 39 | Comments string `json:"comments,omitempty"` |
| 40 | |
| 41 | // Created |
| 42 | // Read Only: true |
| 43 | Created strfmt.Date `json:"created,omitempty"` |
| 44 | |
| 45 | // Custom fields |
| 46 | CustomFields interface{} `json:"custom_fields,omitempty"` |
| 47 | |
| 48 | // Disk (GB) |
| 49 | // Maximum: 2.147483647e+09 |
| 50 | // Minimum: 0 |
| 51 | Disk *int64 `json:"disk,omitempty"` |
| 52 | |
| 53 | // ID |
| 54 | // Read Only: true |
| 55 | ID int64 `json:"id,omitempty"` |
| 56 | |
| 57 | // Last updated |
| 58 | // Read Only: true |
| 59 | LastUpdated strfmt.DateTime `json:"last_updated,omitempty"` |
| 60 | |
| 61 | // Memory (MB) |
| 62 | // Maximum: 2.147483647e+09 |
| 63 | // Minimum: 0 |
| 64 | Memory *int64 `json:"memory,omitempty"` |
| 65 | |
| 66 | // Name |
| 67 | // Required: true |
| 68 | // Max Length: 64 |
| 69 | Name *string `json:"name"` |
| 70 | |
| 71 | // platform |
| 72 | // Required: true |
| 73 | Platform *NestedPlatform `json:"platform"` |
| 74 | |
| 75 | // primary ip |
| 76 | // Required: true |
| 77 | PrimaryIP *VirtualMachineIPAddress `json:"primary_ip"` |
| 78 | |
| 79 | // primary ip4 |
| 80 | // Required: true |
| 81 | PrimaryIp4 *VirtualMachineIPAddress `json:"primary_ip4"` |
| 82 | |
| 83 | // primary ip6 |
| 84 | // Required: true |
| 85 | PrimaryIp6 *VirtualMachineIPAddress `json:"primary_ip6"` |
| 86 | |
| 87 | // role |
| 88 | // Required: true |
| 89 | Role *NestedDeviceRole `json:"role"` |
| 90 | |
| 91 | // status |
| 92 | // Required: true |
| 93 | Status *VirtualMachineStatus `json:"status"` |
| 94 | |
| 95 | // tenant |
| 96 | // Required: true |
| 97 | Tenant *NestedTenant `json:"tenant"` |
| 98 | |
| 99 | // VCPUs |
| 100 | // Maximum: 32767 |
| 101 | // Minimum: 0 |
| 102 | Vcpus *int64 `json:"vcpus,omitempty"` |
| 103 | } |
| 104 | |
| 105 | // Validate validates this virtual machine |
| 106 | func (m *VirtualMachine) Validate(formats strfmt.Registry) error { |
| 107 | var res []error |
| 108 | |
| 109 | if err := m.validateCluster(formats); err != nil { |
| 110 | // prop |
| 111 | res = append(res, err) |
| 112 | } |
| 113 | |
| 114 | if err := m.validateDisk(formats); err != nil { |
| 115 | // prop |
| 116 | res = append(res, err) |
| 117 | } |
| 118 | |
| 119 | if err := m.validateMemory(formats); err != nil { |
| 120 | // prop |
| 121 | res = append(res, err) |
| 122 | } |
| 123 | |
| 124 | if err := m.validateName(formats); err != nil { |
| 125 | // prop |
| 126 | res = append(res, err) |
| 127 | } |
| 128 | |
| 129 | if err := m.validatePlatform(formats); err != nil { |
| 130 | // prop |
| 131 | res = append(res, err) |
| 132 | } |
| 133 | |
| 134 | if err := m.validatePrimaryIP(formats); err != nil { |
| 135 | // prop |
| 136 | res = append(res, err) |
| 137 | } |
| 138 | |
| 139 | if err := m.validatePrimaryIp4(formats); err != nil { |
| 140 | // prop |
| 141 | res = append(res, err) |
| 142 | } |
| 143 | |
| 144 | if err := m.validatePrimaryIp6(formats); err != nil { |
| 145 | // prop |
| 146 | res = append(res, err) |
| 147 | } |
| 148 | |
| 149 | if err := m.validateRole(formats); err != nil { |
| 150 | // prop |
| 151 | res = append(res, err) |
| 152 | } |
| 153 | |
| 154 | if err := m.validateStatus(formats); err != nil { |
| 155 | // prop |
| 156 | res = append(res, err) |
| 157 | } |
| 158 | |
| 159 | if err := m.validateTenant(formats); err != nil { |
| 160 | // prop |
| 161 | res = append(res, err) |
| 162 | } |
| 163 | |
| 164 | if err := m.validateVcpus(formats); err != nil { |
| 165 | // prop |
| 166 | res = append(res, err) |
| 167 | } |
| 168 | |
| 169 | if len(res) > 0 { |
| 170 | return errors.CompositeValidationError(res...) |
| 171 | } |
| 172 | return nil |
| 173 | } |
| 174 | |
| 175 | func (m *VirtualMachine) validateCluster(formats strfmt.Registry) error { |
| 176 | |
| 177 | if err := validate.Required("cluster", "body", m.Cluster); err != nil { |
| 178 | return err |
| 179 | } |
| 180 | |
| 181 | if m.Cluster != nil { |
| 182 | |
| 183 | if err := m.Cluster.Validate(formats); err != nil { |
| 184 | if ve, ok := err.(*errors.Validation); ok { |
| 185 | return ve.ValidateName("cluster") |
| 186 | } |
| 187 | return err |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | return nil |
| 192 | } |
| 193 | |
| 194 | func (m *VirtualMachine) validateDisk(formats strfmt.Registry) error { |
| 195 | |
| 196 | if swag.IsZero(m.Disk) { // not required |
| 197 | return nil |
| 198 | } |
| 199 | |
| 200 | if err := validate.MinimumInt("disk", "body", int64(*m.Disk), 0, false); err != nil { |
| 201 | return err |
| 202 | } |
| 203 | |
| 204 | if err := validate.MaximumInt("disk", "body", int64(*m.Disk), 2.147483647e+09, false); err != nil { |
| 205 | return err |
| 206 | } |
| 207 | |
| 208 | return nil |
| 209 | } |
| 210 | |
| 211 | func (m *VirtualMachine) validateMemory(formats strfmt.Registry) error { |
| 212 | |
| 213 | if swag.IsZero(m.Memory) { // not required |
| 214 | return nil |
| 215 | } |
| 216 | |
| 217 | if err := validate.MinimumInt("memory", "body", int64(*m.Memory), 0, false); err != nil { |
| 218 | return err |
| 219 | } |
| 220 | |
| 221 | if err := validate.MaximumInt("memory", "body", int64(*m.Memory), 2.147483647e+09, false); err != nil { |
| 222 | return err |
| 223 | } |
| 224 | |
| 225 | return nil |
| 226 | } |
| 227 | |
| 228 | func (m *VirtualMachine) validateName(formats strfmt.Registry) error { |
| 229 | |
| 230 | if err := validate.Required("name", "body", m.Name); err != nil { |
| 231 | return err |
| 232 | } |
| 233 | |
| 234 | if err := validate.MaxLength("name", "body", string(*m.Name), 64); err != nil { |
| 235 | return err |
| 236 | } |
| 237 | |
| 238 | return nil |
| 239 | } |
| 240 | |
| 241 | func (m *VirtualMachine) validatePlatform(formats strfmt.Registry) error { |
| 242 | |
| 243 | if err := validate.Required("platform", "body", m.Platform); err != nil { |
| 244 | return err |
| 245 | } |
| 246 | |
| 247 | if m.Platform != nil { |
| 248 | |
| 249 | if err := m.Platform.Validate(formats); err != nil { |
| 250 | if ve, ok := err.(*errors.Validation); ok { |
| 251 | return ve.ValidateName("platform") |
| 252 | } |
| 253 | return err |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | return nil |
| 258 | } |
| 259 | |
| 260 | func (m *VirtualMachine) validatePrimaryIP(formats strfmt.Registry) error { |
| 261 | |
| 262 | if err := validate.Required("primary_ip", "body", m.PrimaryIP); err != nil { |
| 263 | return err |
| 264 | } |
| 265 | |
| 266 | if m.PrimaryIP != nil { |
| 267 | |
| 268 | if err := m.PrimaryIP.Validate(formats); err != nil { |
| 269 | if ve, ok := err.(*errors.Validation); ok { |
| 270 | return ve.ValidateName("primary_ip") |
| 271 | } |
| 272 | return err |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | return nil |
| 277 | } |
| 278 | |
| 279 | func (m *VirtualMachine) validatePrimaryIp4(formats strfmt.Registry) error { |
| 280 | |
| 281 | if err := validate.Required("primary_ip4", "body", m.PrimaryIp4); err != nil { |
| 282 | return err |
| 283 | } |
| 284 | |
| 285 | if m.PrimaryIp4 != nil { |
| 286 | |
| 287 | if err := m.PrimaryIp4.Validate(formats); err != nil { |
| 288 | if ve, ok := err.(*errors.Validation); ok { |
| 289 | return ve.ValidateName("primary_ip4") |
| 290 | } |
| 291 | return err |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | return nil |
| 296 | } |
| 297 | |
| 298 | func (m *VirtualMachine) validatePrimaryIp6(formats strfmt.Registry) error { |
| 299 | |
| 300 | if err := validate.Required("primary_ip6", "body", m.PrimaryIp6); err != nil { |
| 301 | return err |
| 302 | } |
| 303 | |
| 304 | if m.PrimaryIp6 != nil { |
| 305 | |
| 306 | if err := m.PrimaryIp6.Validate(formats); err != nil { |
| 307 | if ve, ok := err.(*errors.Validation); ok { |
| 308 | return ve.ValidateName("primary_ip6") |
| 309 | } |
| 310 | return err |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | return nil |
| 315 | } |
| 316 | |
| 317 | func (m *VirtualMachine) validateRole(formats strfmt.Registry) error { |
| 318 | |
| 319 | if err := validate.Required("role", "body", m.Role); err != nil { |
| 320 | return err |
| 321 | } |
| 322 | |
| 323 | if m.Role != nil { |
| 324 | |
| 325 | if err := m.Role.Validate(formats); err != nil { |
| 326 | if ve, ok := err.(*errors.Validation); ok { |
| 327 | return ve.ValidateName("role") |
| 328 | } |
| 329 | return err |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | return nil |
| 334 | } |
| 335 | |
| 336 | func (m *VirtualMachine) validateStatus(formats strfmt.Registry) error { |
| 337 | |
| 338 | if err := validate.Required("status", "body", m.Status); err != nil { |
| 339 | return err |
| 340 | } |
| 341 | |
| 342 | if m.Status != nil { |
| 343 | |
| 344 | if err := m.Status.Validate(formats); err != nil { |
| 345 | if ve, ok := err.(*errors.Validation); ok { |
| 346 | return ve.ValidateName("status") |
| 347 | } |
| 348 | return err |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | return nil |
| 353 | } |
| 354 | |
| 355 | func (m *VirtualMachine) validateTenant(formats strfmt.Registry) error { |
| 356 | |
| 357 | if err := validate.Required("tenant", "body", m.Tenant); err != nil { |
| 358 | return err |
| 359 | } |
| 360 | |
| 361 | if m.Tenant != nil { |
| 362 | |
| 363 | if err := m.Tenant.Validate(formats); err != nil { |
| 364 | if ve, ok := err.(*errors.Validation); ok { |
| 365 | return ve.ValidateName("tenant") |
| 366 | } |
| 367 | return err |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | return nil |
| 372 | } |
| 373 | |
| 374 | func (m *VirtualMachine) validateVcpus(formats strfmt.Registry) error { |
| 375 | |
| 376 | if swag.IsZero(m.Vcpus) { // not required |
| 377 | return nil |
| 378 | } |
| 379 | |
| 380 | if err := validate.MinimumInt("vcpus", "body", int64(*m.Vcpus), 0, false); err != nil { |
| 381 | return err |
| 382 | } |
| 383 | |
| 384 | if err := validate.MaximumInt("vcpus", "body", int64(*m.Vcpus), 32767, false); err != nil { |
| 385 | return err |
| 386 | } |
| 387 | |
| 388 | return nil |
| 389 | } |
| 390 | |
| 391 | // MarshalBinary interface implementation |
| 392 | func (m *VirtualMachine) MarshalBinary() ([]byte, error) { |
| 393 | if m == nil { |
| 394 | return nil, nil |
| 395 | } |
| 396 | return swag.WriteJSON(m) |
| 397 | } |
| 398 | |
| 399 | // UnmarshalBinary interface implementation |
| 400 | func (m *VirtualMachine) UnmarshalBinary(b []byte) error { |
| 401 | var res VirtualMachine |
| 402 | if err := swag.ReadJSON(b, &res); err != nil { |
| 403 | return err |
| 404 | } |
| 405 | *m = res |
| 406 | return nil |
| 407 | } |