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 | // NestedDeviceType Device type |
| 31 | // swagger:model NestedDeviceType |
| 32 | type NestedDeviceType struct { |
| 33 | |
| 34 | // ID |
| 35 | // Read Only: true |
| 36 | ID int64 `json:"id,omitempty"` |
| 37 | |
| 38 | // manufacturer |
| 39 | // Required: true |
| 40 | Manufacturer *NestedManufacturer `json:"manufacturer"` |
| 41 | |
| 42 | // Model |
| 43 | // Required: true |
| 44 | // Max Length: 50 |
| 45 | Model *string `json:"model"` |
| 46 | |
| 47 | // Slug |
| 48 | // Required: true |
| 49 | // Max Length: 50 |
| 50 | // Pattern: ^[-a-zA-Z0-9_]+$ |
| 51 | Slug *string `json:"slug"` |
| 52 | |
| 53 | // Url |
| 54 | // Read Only: true |
| 55 | URL strfmt.URI `json:"url,omitempty"` |
| 56 | } |
| 57 | |
| 58 | // Validate validates this nested device type |
| 59 | func (m *NestedDeviceType) Validate(formats strfmt.Registry) error { |
| 60 | var res []error |
| 61 | |
| 62 | if err := m.validateManufacturer(formats); err != nil { |
| 63 | // prop |
| 64 | res = append(res, err) |
| 65 | } |
| 66 | |
| 67 | if err := m.validateModel(formats); err != nil { |
| 68 | // prop |
| 69 | res = append(res, err) |
| 70 | } |
| 71 | |
| 72 | if err := m.validateSlug(formats); err != nil { |
| 73 | // prop |
| 74 | res = append(res, err) |
| 75 | } |
| 76 | |
| 77 | if len(res) > 0 { |
| 78 | return errors.CompositeValidationError(res...) |
| 79 | } |
| 80 | return nil |
| 81 | } |
| 82 | |
| 83 | func (m *NestedDeviceType) validateManufacturer(formats strfmt.Registry) error { |
| 84 | |
| 85 | if err := validate.Required("manufacturer", "body", m.Manufacturer); err != nil { |
| 86 | return err |
| 87 | } |
| 88 | |
| 89 | if m.Manufacturer != nil { |
| 90 | |
| 91 | if err := m.Manufacturer.Validate(formats); err != nil { |
| 92 | if ve, ok := err.(*errors.Validation); ok { |
| 93 | return ve.ValidateName("manufacturer") |
| 94 | } |
| 95 | return err |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | return nil |
| 100 | } |
| 101 | |
| 102 | func (m *NestedDeviceType) validateModel(formats strfmt.Registry) error { |
| 103 | |
| 104 | if err := validate.Required("model", "body", m.Model); err != nil { |
| 105 | return err |
| 106 | } |
| 107 | |
| 108 | if err := validate.MaxLength("model", "body", string(*m.Model), 50); err != nil { |
| 109 | return err |
| 110 | } |
| 111 | |
| 112 | return nil |
| 113 | } |
| 114 | |
| 115 | func (m *NestedDeviceType) validateSlug(formats strfmt.Registry) error { |
| 116 | |
| 117 | if err := validate.Required("slug", "body", m.Slug); err != nil { |
| 118 | return err |
| 119 | } |
| 120 | |
| 121 | if err := validate.MaxLength("slug", "body", string(*m.Slug), 50); err != nil { |
| 122 | return err |
| 123 | } |
| 124 | |
| 125 | if err := validate.Pattern("slug", "body", string(*m.Slug), `^[-a-zA-Z0-9_]+$`); err != nil { |
| 126 | return err |
| 127 | } |
| 128 | |
| 129 | return nil |
| 130 | } |
| 131 | |
| 132 | // MarshalBinary interface implementation |
| 133 | func (m *NestedDeviceType) MarshalBinary() ([]byte, error) { |
| 134 | if m == nil { |
| 135 | return nil, nil |
| 136 | } |
| 137 | return swag.WriteJSON(m) |
| 138 | } |
| 139 | |
| 140 | // UnmarshalBinary interface implementation |
| 141 | func (m *NestedDeviceType) UnmarshalBinary(b []byte) error { |
| 142 | var res NestedDeviceType |
| 143 | if err := swag.ReadJSON(b, &res); err != nil { |
| 144 | return err |
| 145 | } |
| 146 | *m = res |
| 147 | return nil |
| 148 | } |