blob: 3b7883bc45286bbcff914f964f5cde5ea3805758 [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// InventoryItem inventory item
31// swagger:model InventoryItem
32type InventoryItem struct {
33
34 // Asset tag
35 //
36 // A unique tag used to identify this item
37 // Max Length: 50
38 AssetTag string `json:"asset_tag,omitempty"`
39
40 // Description
41 // Max Length: 100
42 Description string `json:"description,omitempty"`
43
44 // device
45 // Required: true
46 Device *NestedDevice `json:"device"`
47
48 // Discovered
49 Discovered bool `json:"discovered,omitempty"`
50
51 // ID
52 // Read Only: true
53 ID int64 `json:"id,omitempty"`
54
55 // manufacturer
56 // Required: true
57 Manufacturer *NestedManufacturer `json:"manufacturer"`
58
59 // Name
60 // Required: true
61 // Max Length: 50
62 Name *string `json:"name"`
63
64 // Parent
65 // Required: true
66 Parent *int64 `json:"parent"`
67
68 // Part ID
69 // Max Length: 50
70 PartID string `json:"part_id,omitempty"`
71
72 // Serial number
73 // Max Length: 50
74 Serial string `json:"serial,omitempty"`
75}
76
77// Validate validates this inventory item
78func (m *InventoryItem) Validate(formats strfmt.Registry) error {
79 var res []error
80
81 if err := m.validateAssetTag(formats); err != nil {
82 // prop
83 res = append(res, err)
84 }
85
86 if err := m.validateDescription(formats); err != nil {
87 // prop
88 res = append(res, err)
89 }
90
91 if err := m.validateDevice(formats); err != nil {
92 // prop
93 res = append(res, err)
94 }
95
96 if err := m.validateManufacturer(formats); err != nil {
97 // prop
98 res = append(res, err)
99 }
100
101 if err := m.validateName(formats); err != nil {
102 // prop
103 res = append(res, err)
104 }
105
106 if err := m.validateParent(formats); err != nil {
107 // prop
108 res = append(res, err)
109 }
110
111 if err := m.validatePartID(formats); err != nil {
112 // prop
113 res = append(res, err)
114 }
115
116 if err := m.validateSerial(formats); err != nil {
117 // prop
118 res = append(res, err)
119 }
120
121 if len(res) > 0 {
122 return errors.CompositeValidationError(res...)
123 }
124 return nil
125}
126
127func (m *InventoryItem) validateAssetTag(formats strfmt.Registry) error {
128
129 if swag.IsZero(m.AssetTag) { // not required
130 return nil
131 }
132
133 if err := validate.MaxLength("asset_tag", "body", string(m.AssetTag), 50); err != nil {
134 return err
135 }
136
137 return nil
138}
139
140func (m *InventoryItem) validateDescription(formats strfmt.Registry) error {
141
142 if swag.IsZero(m.Description) { // not required
143 return nil
144 }
145
146 if err := validate.MaxLength("description", "body", string(m.Description), 100); err != nil {
147 return err
148 }
149
150 return nil
151}
152
153func (m *InventoryItem) validateDevice(formats strfmt.Registry) error {
154
155 if err := validate.Required("device", "body", m.Device); err != nil {
156 return err
157 }
158
159 if m.Device != nil {
160
161 if err := m.Device.Validate(formats); err != nil {
162 if ve, ok := err.(*errors.Validation); ok {
163 return ve.ValidateName("device")
164 }
165 return err
166 }
167 }
168
169 return nil
170}
171
172func (m *InventoryItem) validateManufacturer(formats strfmt.Registry) error {
173
174 if err := validate.Required("manufacturer", "body", m.Manufacturer); err != nil {
175 return err
176 }
177
178 if m.Manufacturer != nil {
179
180 if err := m.Manufacturer.Validate(formats); err != nil {
181 if ve, ok := err.(*errors.Validation); ok {
182 return ve.ValidateName("manufacturer")
183 }
184 return err
185 }
186 }
187
188 return nil
189}
190
191func (m *InventoryItem) validateName(formats strfmt.Registry) error {
192
193 if err := validate.Required("name", "body", m.Name); err != nil {
194 return err
195 }
196
197 if err := validate.MaxLength("name", "body", string(*m.Name), 50); err != nil {
198 return err
199 }
200
201 return nil
202}
203
204func (m *InventoryItem) validateParent(formats strfmt.Registry) error {
205
206 if err := validate.Required("parent", "body", m.Parent); err != nil {
207 return err
208 }
209
210 return nil
211}
212
213func (m *InventoryItem) validatePartID(formats strfmt.Registry) error {
214
215 if swag.IsZero(m.PartID) { // not required
216 return nil
217 }
218
219 if err := validate.MaxLength("part_id", "body", string(m.PartID), 50); err != nil {
220 return err
221 }
222
223 return nil
224}
225
226func (m *InventoryItem) validateSerial(formats strfmt.Registry) error {
227
228 if swag.IsZero(m.Serial) { // not required
229 return nil
230 }
231
232 if err := validate.MaxLength("serial", "body", string(m.Serial), 50); err != nil {
233 return err
234 }
235
236 return nil
237}
238
239// MarshalBinary interface implementation
240func (m *InventoryItem) MarshalBinary() ([]byte, error) {
241 if m == nil {
242 return nil, nil
243 }
244 return swag.WriteJSON(m)
245}
246
247// UnmarshalBinary interface implementation
248func (m *InventoryItem) UnmarshalBinary(b []byte) error {
249 var res InventoryItem
250 if err := swag.ReadJSON(b, &res); err != nil {
251 return err
252 }
253 *m = res
254 return nil
255}