github.com/digitalocean/go-netbox@v0.0.2/netbox/models/manufacturer.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 // Copyright 2020 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 18 package models 19 20 // This file was generated by the swagger tool. 21 // Editing this file might prove futile when you re-run the swagger generate command 22 23 import ( 24 "context" 25 26 "github.com/go-openapi/errors" 27 "github.com/go-openapi/strfmt" 28 "github.com/go-openapi/swag" 29 "github.com/go-openapi/validate" 30 ) 31 32 // Manufacturer manufacturer 33 // 34 // swagger:model Manufacturer 35 type Manufacturer struct { 36 37 // Created 38 // Read Only: true 39 // Format: date 40 Created strfmt.Date `json:"created,omitempty"` 41 42 // Custom fields 43 CustomFields interface{} `json:"custom_fields,omitempty"` 44 45 // Description 46 // Max Length: 200 47 Description string `json:"description,omitempty"` 48 49 // Devicetype count 50 // Read Only: true 51 DevicetypeCount int64 `json:"devicetype_count,omitempty"` 52 53 // Display 54 // Read Only: true 55 Display string `json:"display,omitempty"` 56 57 // Id 58 // Read Only: true 59 ID int64 `json:"id,omitempty"` 60 61 // Inventoryitem count 62 // Read Only: true 63 InventoryitemCount int64 `json:"inventoryitem_count,omitempty"` 64 65 // Last updated 66 // Read Only: true 67 // Format: date-time 68 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"` 69 70 // Name 71 // Required: true 72 // Max Length: 100 73 // Min Length: 1 74 Name *string `json:"name"` 75 76 // Platform count 77 // Read Only: true 78 PlatformCount int64 `json:"platform_count,omitempty"` 79 80 // Slug 81 // Required: true 82 // Max Length: 100 83 // Min Length: 1 84 // Pattern: ^[-a-zA-Z0-9_]+$ 85 Slug *string `json:"slug"` 86 87 // Url 88 // Read Only: true 89 // Format: uri 90 URL strfmt.URI `json:"url,omitempty"` 91 } 92 93 // Validate validates this manufacturer 94 func (m *Manufacturer) Validate(formats strfmt.Registry) error { 95 var res []error 96 97 if err := m.validateCreated(formats); err != nil { 98 res = append(res, err) 99 } 100 101 if err := m.validateDescription(formats); err != nil { 102 res = append(res, err) 103 } 104 105 if err := m.validateLastUpdated(formats); err != nil { 106 res = append(res, err) 107 } 108 109 if err := m.validateName(formats); err != nil { 110 res = append(res, err) 111 } 112 113 if err := m.validateSlug(formats); err != nil { 114 res = append(res, err) 115 } 116 117 if err := m.validateURL(formats); err != nil { 118 res = append(res, err) 119 } 120 121 if len(res) > 0 { 122 return errors.CompositeValidationError(res...) 123 } 124 return nil 125 } 126 127 func (m *Manufacturer) validateCreated(formats strfmt.Registry) error { 128 if swag.IsZero(m.Created) { // not required 129 return nil 130 } 131 132 if err := validate.FormatOf("created", "body", "date", m.Created.String(), formats); err != nil { 133 return err 134 } 135 136 return nil 137 } 138 139 func (m *Manufacturer) validateDescription(formats strfmt.Registry) error { 140 if swag.IsZero(m.Description) { // not required 141 return nil 142 } 143 144 if err := validate.MaxLength("description", "body", m.Description, 200); err != nil { 145 return err 146 } 147 148 return nil 149 } 150 151 func (m *Manufacturer) validateLastUpdated(formats strfmt.Registry) error { 152 if swag.IsZero(m.LastUpdated) { // not required 153 return nil 154 } 155 156 if err := validate.FormatOf("last_updated", "body", "date-time", m.LastUpdated.String(), formats); err != nil { 157 return err 158 } 159 160 return nil 161 } 162 163 func (m *Manufacturer) validateName(formats strfmt.Registry) error { 164 165 if err := validate.Required("name", "body", m.Name); err != nil { 166 return err 167 } 168 169 if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { 170 return err 171 } 172 173 if err := validate.MaxLength("name", "body", *m.Name, 100); err != nil { 174 return err 175 } 176 177 return nil 178 } 179 180 func (m *Manufacturer) validateSlug(formats strfmt.Registry) error { 181 182 if err := validate.Required("slug", "body", m.Slug); err != nil { 183 return err 184 } 185 186 if err := validate.MinLength("slug", "body", *m.Slug, 1); err != nil { 187 return err 188 } 189 190 if err := validate.MaxLength("slug", "body", *m.Slug, 100); err != nil { 191 return err 192 } 193 194 if err := validate.Pattern("slug", "body", *m.Slug, `^[-a-zA-Z0-9_]+$`); err != nil { 195 return err 196 } 197 198 return nil 199 } 200 201 func (m *Manufacturer) validateURL(formats strfmt.Registry) error { 202 if swag.IsZero(m.URL) { // not required 203 return nil 204 } 205 206 if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { 207 return err 208 } 209 210 return nil 211 } 212 213 // ContextValidate validate this manufacturer based on the context it is used 214 func (m *Manufacturer) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 215 var res []error 216 217 if err := m.contextValidateCreated(ctx, formats); err != nil { 218 res = append(res, err) 219 } 220 221 if err := m.contextValidateDevicetypeCount(ctx, formats); err != nil { 222 res = append(res, err) 223 } 224 225 if err := m.contextValidateDisplay(ctx, formats); err != nil { 226 res = append(res, err) 227 } 228 229 if err := m.contextValidateID(ctx, formats); err != nil { 230 res = append(res, err) 231 } 232 233 if err := m.contextValidateInventoryitemCount(ctx, formats); err != nil { 234 res = append(res, err) 235 } 236 237 if err := m.contextValidateLastUpdated(ctx, formats); err != nil { 238 res = append(res, err) 239 } 240 241 if err := m.contextValidatePlatformCount(ctx, formats); err != nil { 242 res = append(res, err) 243 } 244 245 if err := m.contextValidateURL(ctx, formats); err != nil { 246 res = append(res, err) 247 } 248 249 if len(res) > 0 { 250 return errors.CompositeValidationError(res...) 251 } 252 return nil 253 } 254 255 func (m *Manufacturer) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error { 256 257 if err := validate.ReadOnly(ctx, "created", "body", strfmt.Date(m.Created)); err != nil { 258 return err 259 } 260 261 return nil 262 } 263 264 func (m *Manufacturer) contextValidateDevicetypeCount(ctx context.Context, formats strfmt.Registry) error { 265 266 if err := validate.ReadOnly(ctx, "devicetype_count", "body", int64(m.DevicetypeCount)); err != nil { 267 return err 268 } 269 270 return nil 271 } 272 273 func (m *Manufacturer) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error { 274 275 if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil { 276 return err 277 } 278 279 return nil 280 } 281 282 func (m *Manufacturer) contextValidateID(ctx context.Context, formats strfmt.Registry) error { 283 284 if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil { 285 return err 286 } 287 288 return nil 289 } 290 291 func (m *Manufacturer) contextValidateInventoryitemCount(ctx context.Context, formats strfmt.Registry) error { 292 293 if err := validate.ReadOnly(ctx, "inventoryitem_count", "body", int64(m.InventoryitemCount)); err != nil { 294 return err 295 } 296 297 return nil 298 } 299 300 func (m *Manufacturer) contextValidateLastUpdated(ctx context.Context, formats strfmt.Registry) error { 301 302 if err := validate.ReadOnly(ctx, "last_updated", "body", strfmt.DateTime(m.LastUpdated)); err != nil { 303 return err 304 } 305 306 return nil 307 } 308 309 func (m *Manufacturer) contextValidatePlatformCount(ctx context.Context, formats strfmt.Registry) error { 310 311 if err := validate.ReadOnly(ctx, "platform_count", "body", int64(m.PlatformCount)); err != nil { 312 return err 313 } 314 315 return nil 316 } 317 318 func (m *Manufacturer) contextValidateURL(ctx context.Context, formats strfmt.Registry) error { 319 320 if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil { 321 return err 322 } 323 324 return nil 325 } 326 327 // MarshalBinary interface implementation 328 func (m *Manufacturer) MarshalBinary() ([]byte, error) { 329 if m == nil { 330 return nil, nil 331 } 332 return swag.WriteJSON(m) 333 } 334 335 // UnmarshalBinary interface implementation 336 func (m *Manufacturer) UnmarshalBinary(b []byte) error { 337 var res Manufacturer 338 if err := swag.ReadJSON(b, &res); err != nil { 339 return err 340 } 341 *m = res 342 return nil 343 }