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 | // Service service |
| 31 | // swagger:model Service |
| 32 | type Service struct { |
| 33 | |
| 34 | // Created |
| 35 | // Read Only: true |
| 36 | Created strfmt.Date `json:"created,omitempty"` |
| 37 | |
| 38 | // Description |
| 39 | // Max Length: 100 |
| 40 | Description string `json:"description,omitempty"` |
| 41 | |
| 42 | // device |
| 43 | // Required: true |
| 44 | Device *NestedDevice `json:"device"` |
| 45 | |
| 46 | // ID |
| 47 | // Read Only: true |
| 48 | ID int64 `json:"id,omitempty"` |
| 49 | |
| 50 | // ipaddresses |
| 51 | // Required: true |
| 52 | Ipaddresses ServiceIpaddresses `json:"ipaddresses"` |
| 53 | |
| 54 | // Last updated |
| 55 | // Read Only: true |
| 56 | LastUpdated strfmt.DateTime `json:"last_updated,omitempty"` |
| 57 | |
| 58 | // Name |
| 59 | // Required: true |
| 60 | // Max Length: 30 |
| 61 | Name *string `json:"name"` |
| 62 | |
| 63 | // Port number |
| 64 | // Required: true |
| 65 | // Maximum: 65535 |
| 66 | // Minimum: 1 |
| 67 | Port *int64 `json:"port"` |
| 68 | |
| 69 | // protocol |
| 70 | // Required: true |
| 71 | Protocol *ServiceProtocol `json:"protocol"` |
| 72 | |
| 73 | // virtual machine |
| 74 | // Required: true |
| 75 | VirtualMachine *NestedVirtualMachine `json:"virtual_machine"` |
| 76 | } |
| 77 | |
| 78 | // Validate validates this service |
| 79 | func (m *Service) Validate(formats strfmt.Registry) error { |
| 80 | var res []error |
| 81 | |
| 82 | if err := m.validateDescription(formats); err != nil { |
| 83 | // prop |
| 84 | res = append(res, err) |
| 85 | } |
| 86 | |
| 87 | if err := m.validateDevice(formats); err != nil { |
| 88 | // prop |
| 89 | res = append(res, err) |
| 90 | } |
| 91 | |
| 92 | if err := m.validateIpaddresses(formats); err != nil { |
| 93 | // prop |
| 94 | res = append(res, err) |
| 95 | } |
| 96 | |
| 97 | if err := m.validateName(formats); err != nil { |
| 98 | // prop |
| 99 | res = append(res, err) |
| 100 | } |
| 101 | |
| 102 | if err := m.validatePort(formats); err != nil { |
| 103 | // prop |
| 104 | res = append(res, err) |
| 105 | } |
| 106 | |
| 107 | if err := m.validateProtocol(formats); err != nil { |
| 108 | // prop |
| 109 | res = append(res, err) |
| 110 | } |
| 111 | |
| 112 | if err := m.validateVirtualMachine(formats); err != nil { |
| 113 | // prop |
| 114 | res = append(res, err) |
| 115 | } |
| 116 | |
| 117 | if len(res) > 0 { |
| 118 | return errors.CompositeValidationError(res...) |
| 119 | } |
| 120 | return nil |
| 121 | } |
| 122 | |
| 123 | func (m *Service) validateDescription(formats strfmt.Registry) error { |
| 124 | |
| 125 | if swag.IsZero(m.Description) { // not required |
| 126 | return nil |
| 127 | } |
| 128 | |
| 129 | if err := validate.MaxLength("description", "body", string(m.Description), 100); err != nil { |
| 130 | return err |
| 131 | } |
| 132 | |
| 133 | return nil |
| 134 | } |
| 135 | |
| 136 | func (m *Service) validateDevice(formats strfmt.Registry) error { |
| 137 | |
| 138 | if err := validate.Required("device", "body", m.Device); err != nil { |
| 139 | return err |
| 140 | } |
| 141 | |
| 142 | if m.Device != nil { |
| 143 | |
| 144 | if err := m.Device.Validate(formats); err != nil { |
| 145 | if ve, ok := err.(*errors.Validation); ok { |
| 146 | return ve.ValidateName("device") |
| 147 | } |
| 148 | return err |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | return nil |
| 153 | } |
| 154 | |
| 155 | func (m *Service) validateIpaddresses(formats strfmt.Registry) error { |
| 156 | |
| 157 | if err := validate.Required("ipaddresses", "body", m.Ipaddresses); err != nil { |
| 158 | return err |
| 159 | } |
| 160 | |
| 161 | if err := m.Ipaddresses.Validate(formats); err != nil { |
| 162 | if ve, ok := err.(*errors.Validation); ok { |
| 163 | return ve.ValidateName("ipaddresses") |
| 164 | } |
| 165 | return err |
| 166 | } |
| 167 | |
| 168 | return nil |
| 169 | } |
| 170 | |
| 171 | func (m *Service) validateName(formats strfmt.Registry) error { |
| 172 | |
| 173 | if err := validate.Required("name", "body", m.Name); err != nil { |
| 174 | return err |
| 175 | } |
| 176 | |
| 177 | if err := validate.MaxLength("name", "body", string(*m.Name), 30); err != nil { |
| 178 | return err |
| 179 | } |
| 180 | |
| 181 | return nil |
| 182 | } |
| 183 | |
| 184 | func (m *Service) validatePort(formats strfmt.Registry) error { |
| 185 | |
| 186 | if err := validate.Required("port", "body", m.Port); err != nil { |
| 187 | return err |
| 188 | } |
| 189 | |
| 190 | if err := validate.MinimumInt("port", "body", int64(*m.Port), 1, false); err != nil { |
| 191 | return err |
| 192 | } |
| 193 | |
| 194 | if err := validate.MaximumInt("port", "body", int64(*m.Port), 65535, false); err != nil { |
| 195 | return err |
| 196 | } |
| 197 | |
| 198 | return nil |
| 199 | } |
| 200 | |
| 201 | func (m *Service) validateProtocol(formats strfmt.Registry) error { |
| 202 | |
| 203 | if err := validate.Required("protocol", "body", m.Protocol); err != nil { |
| 204 | return err |
| 205 | } |
| 206 | |
| 207 | if m.Protocol != nil { |
| 208 | |
| 209 | if err := m.Protocol.Validate(formats); err != nil { |
| 210 | if ve, ok := err.(*errors.Validation); ok { |
| 211 | return ve.ValidateName("protocol") |
| 212 | } |
| 213 | return err |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | return nil |
| 218 | } |
| 219 | |
| 220 | func (m *Service) validateVirtualMachine(formats strfmt.Registry) error { |
| 221 | |
| 222 | if err := validate.Required("virtual_machine", "body", m.VirtualMachine); err != nil { |
| 223 | return err |
| 224 | } |
| 225 | |
| 226 | if m.VirtualMachine != nil { |
| 227 | |
| 228 | if err := m.VirtualMachine.Validate(formats); err != nil { |
| 229 | if ve, ok := err.(*errors.Validation); ok { |
| 230 | return ve.ValidateName("virtual_machine") |
| 231 | } |
| 232 | return err |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | return nil |
| 237 | } |
| 238 | |
| 239 | // MarshalBinary interface implementation |
| 240 | func (m *Service) MarshalBinary() ([]byte, error) { |
| 241 | if m == nil { |
| 242 | return nil, nil |
| 243 | } |
| 244 | return swag.WriteJSON(m) |
| 245 | } |
| 246 | |
| 247 | // UnmarshalBinary interface implementation |
| 248 | func (m *Service) UnmarshalBinary(b []byte) error { |
| 249 | var res Service |
| 250 | if err := swag.ReadJSON(b, &res); err != nil { |
| 251 | return err |
| 252 | } |
| 253 | *m = res |
| 254 | return nil |
| 255 | } |