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 | "encoding/json" |
| 24 | |
| 25 | strfmt "github.com/go-openapi/strfmt" |
| 26 | |
| 27 | "github.com/go-openapi/errors" |
| 28 | "github.com/go-openapi/swag" |
| 29 | "github.com/go-openapi/validate" |
| 30 | ) |
| 31 | |
| 32 | // WritableInterfaceTemplate writable interface template |
| 33 | // swagger:model WritableInterfaceTemplate |
| 34 | type WritableInterfaceTemplate struct { |
| 35 | |
| 36 | // Device type |
| 37 | // Required: true |
| 38 | DeviceType *int64 `json:"device_type"` |
| 39 | |
| 40 | // Form factor |
| 41 | FormFactor int64 `json:"form_factor,omitempty"` |
| 42 | |
| 43 | // ID |
| 44 | // Read Only: true |
| 45 | ID int64 `json:"id,omitempty"` |
| 46 | |
| 47 | // Management only |
| 48 | MgmtOnly bool `json:"mgmt_only,omitempty"` |
| 49 | |
| 50 | // Name |
| 51 | // Required: true |
| 52 | // Max Length: 64 |
| 53 | Name *string `json:"name"` |
| 54 | } |
| 55 | |
| 56 | // Validate validates this writable interface template |
| 57 | func (m *WritableInterfaceTemplate) Validate(formats strfmt.Registry) error { |
| 58 | var res []error |
| 59 | |
| 60 | if err := m.validateDeviceType(formats); err != nil { |
| 61 | // prop |
| 62 | res = append(res, err) |
| 63 | } |
| 64 | |
| 65 | if err := m.validateFormFactor(formats); err != nil { |
| 66 | // prop |
| 67 | res = append(res, err) |
| 68 | } |
| 69 | |
| 70 | if err := m.validateName(formats); err != nil { |
| 71 | // prop |
| 72 | res = append(res, err) |
| 73 | } |
| 74 | |
| 75 | if len(res) > 0 { |
| 76 | return errors.CompositeValidationError(res...) |
| 77 | } |
| 78 | return nil |
| 79 | } |
| 80 | |
| 81 | func (m *WritableInterfaceTemplate) validateDeviceType(formats strfmt.Registry) error { |
| 82 | |
| 83 | if err := validate.Required("device_type", "body", m.DeviceType); err != nil { |
| 84 | return err |
| 85 | } |
| 86 | |
| 87 | return nil |
| 88 | } |
| 89 | |
| 90 | var writableInterfaceTemplateTypeFormFactorPropEnum []interface{} |
| 91 | |
| 92 | func init() { |
| 93 | var res []int64 |
| 94 | if err := json.Unmarshal([]byte(`[0,200,800,1000,1150,1170,1050,1100,1200,1300,1310,1320,1350,1400,1500,1510,1520,1550,1600,2600,2610,2620,2630,2640,3010,3020,3040,3080,3160,4000,4010,4040,4050,5000,5050,5100,5150,5200,32767]`), &res); err != nil { |
| 95 | panic(err) |
| 96 | } |
| 97 | for _, v := range res { |
| 98 | writableInterfaceTemplateTypeFormFactorPropEnum = append(writableInterfaceTemplateTypeFormFactorPropEnum, v) |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | // prop value enum |
| 103 | func (m *WritableInterfaceTemplate) validateFormFactorEnum(path, location string, value int64) error { |
| 104 | if err := validate.Enum(path, location, value, writableInterfaceTemplateTypeFormFactorPropEnum); err != nil { |
| 105 | return err |
| 106 | } |
| 107 | return nil |
| 108 | } |
| 109 | |
| 110 | func (m *WritableInterfaceTemplate) validateFormFactor(formats strfmt.Registry) error { |
| 111 | |
| 112 | if swag.IsZero(m.FormFactor) { // not required |
| 113 | return nil |
| 114 | } |
| 115 | |
| 116 | // value enum |
| 117 | if err := m.validateFormFactorEnum("form_factor", "body", m.FormFactor); err != nil { |
| 118 | return err |
| 119 | } |
| 120 | |
| 121 | return nil |
| 122 | } |
| 123 | |
| 124 | func (m *WritableInterfaceTemplate) validateName(formats strfmt.Registry) error { |
| 125 | |
| 126 | if err := validate.Required("name", "body", m.Name); err != nil { |
| 127 | return err |
| 128 | } |
| 129 | |
| 130 | if err := validate.MaxLength("name", "body", string(*m.Name), 64); err != nil { |
| 131 | return err |
| 132 | } |
| 133 | |
| 134 | return nil |
| 135 | } |
| 136 | |
| 137 | // MarshalBinary interface implementation |
| 138 | func (m *WritableInterfaceTemplate) MarshalBinary() ([]byte, error) { |
| 139 | if m == nil { |
| 140 | return nil, nil |
| 141 | } |
| 142 | return swag.WriteJSON(m) |
| 143 | } |
| 144 | |
| 145 | // UnmarshalBinary interface implementation |
| 146 | func (m *WritableInterfaceTemplate) UnmarshalBinary(b []byte) error { |
| 147 | var res WritableInterfaceTemplate |
| 148 | if err := swag.ReadJSON(b, &res); err != nil { |
| 149 | return err |
| 150 | } |
| 151 | *m = res |
| 152 | return nil |
| 153 | } |