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 | // WritableInventoryItem writable inventory item |
| 31 | // swagger:model WritableInventoryItem |
| 32 | type WritableInventoryItem 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 *int64 `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 | Manufacturer int64 `json:"manufacturer,omitempty"` |
| 57 | |
| 58 | // Name |
| 59 | // Required: true |
| 60 | // Max Length: 50 |
| 61 | Name *string `json:"name"` |
| 62 | |
| 63 | // Parent |
| 64 | Parent int64 `json:"parent,omitempty"` |
| 65 | |
| 66 | // Part ID |
| 67 | // Max Length: 50 |
| 68 | PartID string `json:"part_id,omitempty"` |
| 69 | |
| 70 | // Serial number |
| 71 | // Max Length: 50 |
| 72 | Serial string `json:"serial,omitempty"` |
| 73 | } |
| 74 | |
| 75 | // Validate validates this writable inventory item |
| 76 | func (m *WritableInventoryItem) Validate(formats strfmt.Registry) error { |
| 77 | var res []error |
| 78 | |
| 79 | if err := m.validateAssetTag(formats); err != nil { |
| 80 | // prop |
| 81 | res = append(res, err) |
| 82 | } |
| 83 | |
| 84 | if err := m.validateDescription(formats); err != nil { |
| 85 | // prop |
| 86 | res = append(res, err) |
| 87 | } |
| 88 | |
| 89 | if err := m.validateDevice(formats); err != nil { |
| 90 | // prop |
| 91 | res = append(res, err) |
| 92 | } |
| 93 | |
| 94 | if err := m.validateName(formats); err != nil { |
| 95 | // prop |
| 96 | res = append(res, err) |
| 97 | } |
| 98 | |
| 99 | if err := m.validatePartID(formats); err != nil { |
| 100 | // prop |
| 101 | res = append(res, err) |
| 102 | } |
| 103 | |
| 104 | if err := m.validateSerial(formats); err != nil { |
| 105 | // prop |
| 106 | res = append(res, err) |
| 107 | } |
| 108 | |
| 109 | if len(res) > 0 { |
| 110 | return errors.CompositeValidationError(res...) |
| 111 | } |
| 112 | return nil |
| 113 | } |
| 114 | |
| 115 | func (m *WritableInventoryItem) validateAssetTag(formats strfmt.Registry) error { |
| 116 | |
| 117 | if swag.IsZero(m.AssetTag) { // not required |
| 118 | return nil |
| 119 | } |
| 120 | |
| 121 | if err := validate.MaxLength("asset_tag", "body", string(m.AssetTag), 50); err != nil { |
| 122 | return err |
| 123 | } |
| 124 | |
| 125 | return nil |
| 126 | } |
| 127 | |
| 128 | func (m *WritableInventoryItem) validateDescription(formats strfmt.Registry) error { |
| 129 | |
| 130 | if swag.IsZero(m.Description) { // not required |
| 131 | return nil |
| 132 | } |
| 133 | |
| 134 | if err := validate.MaxLength("description", "body", string(m.Description), 100); err != nil { |
| 135 | return err |
| 136 | } |
| 137 | |
| 138 | return nil |
| 139 | } |
| 140 | |
| 141 | func (m *WritableInventoryItem) validateDevice(formats strfmt.Registry) error { |
| 142 | |
| 143 | if err := validate.Required("device", "body", m.Device); err != nil { |
| 144 | return err |
| 145 | } |
| 146 | |
| 147 | return nil |
| 148 | } |
| 149 | |
| 150 | func (m *WritableInventoryItem) validateName(formats strfmt.Registry) error { |
| 151 | |
| 152 | if err := validate.Required("name", "body", m.Name); err != nil { |
| 153 | return err |
| 154 | } |
| 155 | |
| 156 | if err := validate.MaxLength("name", "body", string(*m.Name), 50); err != nil { |
| 157 | return err |
| 158 | } |
| 159 | |
| 160 | return nil |
| 161 | } |
| 162 | |
| 163 | func (m *WritableInventoryItem) validatePartID(formats strfmt.Registry) error { |
| 164 | |
| 165 | if swag.IsZero(m.PartID) { // not required |
| 166 | return nil |
| 167 | } |
| 168 | |
| 169 | if err := validate.MaxLength("part_id", "body", string(m.PartID), 50); err != nil { |
| 170 | return err |
| 171 | } |
| 172 | |
| 173 | return nil |
| 174 | } |
| 175 | |
| 176 | func (m *WritableInventoryItem) validateSerial(formats strfmt.Registry) error { |
| 177 | |
| 178 | if swag.IsZero(m.Serial) { // not required |
| 179 | return nil |
| 180 | } |
| 181 | |
| 182 | if err := validate.MaxLength("serial", "body", string(m.Serial), 50); err != nil { |
| 183 | return err |
| 184 | } |
| 185 | |
| 186 | return nil |
| 187 | } |
| 188 | |
| 189 | // MarshalBinary interface implementation |
| 190 | func (m *WritableInventoryItem) MarshalBinary() ([]byte, error) { |
| 191 | if m == nil { |
| 192 | return nil, nil |
| 193 | } |
| 194 | return swag.WriteJSON(m) |
| 195 | } |
| 196 | |
| 197 | // UnmarshalBinary interface implementation |
| 198 | func (m *WritableInventoryItem) UnmarshalBinary(b []byte) error { |
| 199 | var res WritableInventoryItem |
| 200 | if err := swag.ReadJSON(b, &res); err != nil { |
| 201 | return err |
| 202 | } |
| 203 | *m = res |
| 204 | return nil |
| 205 | } |