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 | // Manufacturer manufacturer |
| 31 | // swagger:model Manufacturer |
| 32 | type Manufacturer struct { |
| 33 | |
| 34 | // ID |
| 35 | // Read Only: true |
| 36 | ID int64 `json:"id,omitempty"` |
| 37 | |
| 38 | // Name |
| 39 | // Required: true |
| 40 | // Max Length: 50 |
| 41 | Name *string `json:"name"` |
| 42 | |
| 43 | // Slug |
| 44 | // Required: true |
| 45 | // Max Length: 50 |
| 46 | // Pattern: ^[-a-zA-Z0-9_]+$ |
| 47 | Slug *string `json:"slug"` |
| 48 | } |
| 49 | |
| 50 | // Validate validates this manufacturer |
| 51 | func (m *Manufacturer) Validate(formats strfmt.Registry) error { |
| 52 | var res []error |
| 53 | |
| 54 | if err := m.validateName(formats); err != nil { |
| 55 | // prop |
| 56 | res = append(res, err) |
| 57 | } |
| 58 | |
| 59 | if err := m.validateSlug(formats); err != nil { |
| 60 | // prop |
| 61 | res = append(res, err) |
| 62 | } |
| 63 | |
| 64 | if len(res) > 0 { |
| 65 | return errors.CompositeValidationError(res...) |
| 66 | } |
| 67 | return nil |
| 68 | } |
| 69 | |
| 70 | func (m *Manufacturer) validateName(formats strfmt.Registry) error { |
| 71 | |
| 72 | if err := validate.Required("name", "body", m.Name); err != nil { |
| 73 | return err |
| 74 | } |
| 75 | |
| 76 | if err := validate.MaxLength("name", "body", string(*m.Name), 50); err != nil { |
| 77 | return err |
| 78 | } |
| 79 | |
| 80 | return nil |
| 81 | } |
| 82 | |
| 83 | func (m *Manufacturer) validateSlug(formats strfmt.Registry) error { |
| 84 | |
| 85 | if err := validate.Required("slug", "body", m.Slug); err != nil { |
| 86 | return err |
| 87 | } |
| 88 | |
| 89 | if err := validate.MaxLength("slug", "body", string(*m.Slug), 50); err != nil { |
| 90 | return err |
| 91 | } |
| 92 | |
| 93 | if err := validate.Pattern("slug", "body", string(*m.Slug), `^[-a-zA-Z0-9_]+$`); err != nil { |
| 94 | return err |
| 95 | } |
| 96 | |
| 97 | return nil |
| 98 | } |
| 99 | |
| 100 | // MarshalBinary interface implementation |
| 101 | func (m *Manufacturer) MarshalBinary() ([]byte, error) { |
| 102 | if m == nil { |
| 103 | return nil, nil |
| 104 | } |
| 105 | return swag.WriteJSON(m) |
| 106 | } |
| 107 | |
| 108 | // UnmarshalBinary interface implementation |
| 109 | func (m *Manufacturer) UnmarshalBinary(b []byte) error { |
| 110 | var res Manufacturer |
| 111 | if err := swag.ReadJSON(b, &res); err != nil { |
| 112 | return err |
| 113 | } |
| 114 | *m = res |
| 115 | return nil |
| 116 | } |