blob: 9843586a4916f7959ce4ae3a68f81cfcae0fb180 [file] [log] [blame]
Serge Bazanskicc25bdf2018-10-25 14:02:58 +02001// 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
17package 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
22import (
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// DeviceBay device bay
31// swagger:model DeviceBay
32type DeviceBay struct {
33
34 // device
35 // Required: true
36 Device *NestedDevice `json:"device"`
37
38 // ID
39 // Read Only: true
40 ID int64 `json:"id,omitempty"`
41
42 // installed device
43 // Required: true
44 InstalledDevice *NestedDevice `json:"installed_device"`
45
46 // Name
47 // Required: true
48 // Max Length: 50
49 Name *string `json:"name"`
50}
51
52// Validate validates this device bay
53func (m *DeviceBay) Validate(formats strfmt.Registry) error {
54 var res []error
55
56 if err := m.validateDevice(formats); err != nil {
57 // prop
58 res = append(res, err)
59 }
60
61 if err := m.validateInstalledDevice(formats); err != nil {
62 // prop
63 res = append(res, err)
64 }
65
66 if err := m.validateName(formats); err != nil {
67 // prop
68 res = append(res, err)
69 }
70
71 if len(res) > 0 {
72 return errors.CompositeValidationError(res...)
73 }
74 return nil
75}
76
77func (m *DeviceBay) validateDevice(formats strfmt.Registry) error {
78
79 if err := validate.Required("device", "body", m.Device); err != nil {
80 return err
81 }
82
83 if m.Device != nil {
84
85 if err := m.Device.Validate(formats); err != nil {
86 if ve, ok := err.(*errors.Validation); ok {
87 return ve.ValidateName("device")
88 }
89 return err
90 }
91 }
92
93 return nil
94}
95
96func (m *DeviceBay) validateInstalledDevice(formats strfmt.Registry) error {
97
98 if err := validate.Required("installed_device", "body", m.InstalledDevice); err != nil {
99 return err
100 }
101
102 if m.InstalledDevice != nil {
103
104 if err := m.InstalledDevice.Validate(formats); err != nil {
105 if ve, ok := err.(*errors.Validation); ok {
106 return ve.ValidateName("installed_device")
107 }
108 return err
109 }
110 }
111
112 return nil
113}
114
115func (m *DeviceBay) validateName(formats strfmt.Registry) error {
116
117 if err := validate.Required("name", "body", m.Name); err != nil {
118 return err
119 }
120
121 if err := validate.MaxLength("name", "body", string(*m.Name), 50); err != nil {
122 return err
123 }
124
125 return nil
126}
127
128// MarshalBinary interface implementation
129func (m *DeviceBay) MarshalBinary() ([]byte, error) {
130 if m == nil {
131 return nil, nil
132 }
133 return swag.WriteJSON(m)
134}
135
136// UnmarshalBinary interface implementation
137func (m *DeviceBay) UnmarshalBinary(b []byte) error {
138 var res DeviceBay
139 if err := swag.ReadJSON(b, &res); err != nil {
140 return err
141 }
142 *m = res
143 return nil
144}