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 | // InterfaceCircuitTermination Circuit termination |
| 33 | // swagger:model InterfaceCircuitTermination |
| 34 | type InterfaceCircuitTermination struct { |
| 35 | |
| 36 | // circuit |
| 37 | // Required: true |
| 38 | Circuit *InterfaceNestedCircuit `json:"circuit"` |
| 39 | |
| 40 | // ID |
| 41 | // Read Only: true |
| 42 | ID int64 `json:"id,omitempty"` |
| 43 | |
| 44 | // Port speed (Kbps) |
| 45 | // Required: true |
| 46 | // Maximum: 2.147483647e+09 |
| 47 | // Minimum: 0 |
| 48 | PortSpeed *int64 `json:"port_speed"` |
| 49 | |
| 50 | // Patch panel/port(s) |
| 51 | // Max Length: 100 |
| 52 | PpInfo string `json:"pp_info,omitempty"` |
| 53 | |
| 54 | // Termination |
| 55 | // Required: true |
| 56 | TermSide *string `json:"term_side"` |
| 57 | |
| 58 | // Upstream speed (Kbps) |
| 59 | // |
| 60 | // Upstream speed, if different from port speed |
| 61 | // Maximum: 2.147483647e+09 |
| 62 | // Minimum: 0 |
| 63 | UpstreamSpeed *int64 `json:"upstream_speed,omitempty"` |
| 64 | |
| 65 | // Cross-connect ID |
| 66 | // Max Length: 50 |
| 67 | XconnectID string `json:"xconnect_id,omitempty"` |
| 68 | } |
| 69 | |
| 70 | // Validate validates this interface circuit termination |
| 71 | func (m *InterfaceCircuitTermination) Validate(formats strfmt.Registry) error { |
| 72 | var res []error |
| 73 | |
| 74 | if err := m.validateCircuit(formats); err != nil { |
| 75 | // prop |
| 76 | res = append(res, err) |
| 77 | } |
| 78 | |
| 79 | if err := m.validatePortSpeed(formats); err != nil { |
| 80 | // prop |
| 81 | res = append(res, err) |
| 82 | } |
| 83 | |
| 84 | if err := m.validatePpInfo(formats); err != nil { |
| 85 | // prop |
| 86 | res = append(res, err) |
| 87 | } |
| 88 | |
| 89 | if err := m.validateTermSide(formats); err != nil { |
| 90 | // prop |
| 91 | res = append(res, err) |
| 92 | } |
| 93 | |
| 94 | if err := m.validateUpstreamSpeed(formats); err != nil { |
| 95 | // prop |
| 96 | res = append(res, err) |
| 97 | } |
| 98 | |
| 99 | if err := m.validateXconnectID(formats); err != nil { |
| 100 | // prop |
| 101 | res = append(res, err) |
| 102 | } |
| 103 | |
| 104 | if len(res) > 0 { |
| 105 | return errors.CompositeValidationError(res...) |
| 106 | } |
| 107 | return nil |
| 108 | } |
| 109 | |
| 110 | func (m *InterfaceCircuitTermination) validateCircuit(formats strfmt.Registry) error { |
| 111 | |
| 112 | if err := validate.Required("circuit", "body", m.Circuit); err != nil { |
| 113 | return err |
| 114 | } |
| 115 | |
| 116 | if m.Circuit != nil { |
| 117 | |
| 118 | if err := m.Circuit.Validate(formats); err != nil { |
| 119 | if ve, ok := err.(*errors.Validation); ok { |
| 120 | return ve.ValidateName("circuit") |
| 121 | } |
| 122 | return err |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | return nil |
| 127 | } |
| 128 | |
| 129 | func (m *InterfaceCircuitTermination) validatePortSpeed(formats strfmt.Registry) error { |
| 130 | |
| 131 | if err := validate.Required("port_speed", "body", m.PortSpeed); err != nil { |
| 132 | return err |
| 133 | } |
| 134 | |
| 135 | if err := validate.MinimumInt("port_speed", "body", int64(*m.PortSpeed), 0, false); err != nil { |
| 136 | return err |
| 137 | } |
| 138 | |
| 139 | if err := validate.MaximumInt("port_speed", "body", int64(*m.PortSpeed), 2.147483647e+09, false); err != nil { |
| 140 | return err |
| 141 | } |
| 142 | |
| 143 | return nil |
| 144 | } |
| 145 | |
| 146 | func (m *InterfaceCircuitTermination) validatePpInfo(formats strfmt.Registry) error { |
| 147 | |
| 148 | if swag.IsZero(m.PpInfo) { // not required |
| 149 | return nil |
| 150 | } |
| 151 | |
| 152 | if err := validate.MaxLength("pp_info", "body", string(m.PpInfo), 100); err != nil { |
| 153 | return err |
| 154 | } |
| 155 | |
| 156 | return nil |
| 157 | } |
| 158 | |
| 159 | var interfaceCircuitTerminationTypeTermSidePropEnum []interface{} |
| 160 | |
| 161 | func init() { |
| 162 | var res []string |
| 163 | if err := json.Unmarshal([]byte(`["A","Z"]`), &res); err != nil { |
| 164 | panic(err) |
| 165 | } |
| 166 | for _, v := range res { |
| 167 | interfaceCircuitTerminationTypeTermSidePropEnum = append(interfaceCircuitTerminationTypeTermSidePropEnum, v) |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | const ( |
| 172 | // InterfaceCircuitTerminationTermSideA captures enum value "A" |
| 173 | InterfaceCircuitTerminationTermSideA string = "A" |
| 174 | // InterfaceCircuitTerminationTermSideZ captures enum value "Z" |
| 175 | InterfaceCircuitTerminationTermSideZ string = "Z" |
| 176 | ) |
| 177 | |
| 178 | // prop value enum |
| 179 | func (m *InterfaceCircuitTermination) validateTermSideEnum(path, location string, value string) error { |
| 180 | if err := validate.Enum(path, location, value, interfaceCircuitTerminationTypeTermSidePropEnum); err != nil { |
| 181 | return err |
| 182 | } |
| 183 | return nil |
| 184 | } |
| 185 | |
| 186 | func (m *InterfaceCircuitTermination) validateTermSide(formats strfmt.Registry) error { |
| 187 | |
| 188 | if err := validate.Required("term_side", "body", m.TermSide); err != nil { |
| 189 | return err |
| 190 | } |
| 191 | |
| 192 | // value enum |
| 193 | if err := m.validateTermSideEnum("term_side", "body", *m.TermSide); err != nil { |
| 194 | return err |
| 195 | } |
| 196 | |
| 197 | return nil |
| 198 | } |
| 199 | |
| 200 | func (m *InterfaceCircuitTermination) validateUpstreamSpeed(formats strfmt.Registry) error { |
| 201 | |
| 202 | if swag.IsZero(m.UpstreamSpeed) { // not required |
| 203 | return nil |
| 204 | } |
| 205 | |
| 206 | if err := validate.MinimumInt("upstream_speed", "body", int64(*m.UpstreamSpeed), 0, false); err != nil { |
| 207 | return err |
| 208 | } |
| 209 | |
| 210 | if err := validate.MaximumInt("upstream_speed", "body", int64(*m.UpstreamSpeed), 2.147483647e+09, false); err != nil { |
| 211 | return err |
| 212 | } |
| 213 | |
| 214 | return nil |
| 215 | } |
| 216 | |
| 217 | func (m *InterfaceCircuitTermination) validateXconnectID(formats strfmt.Registry) error { |
| 218 | |
| 219 | if swag.IsZero(m.XconnectID) { // not required |
| 220 | return nil |
| 221 | } |
| 222 | |
| 223 | if err := validate.MaxLength("xconnect_id", "body", string(m.XconnectID), 50); err != nil { |
| 224 | return err |
| 225 | } |
| 226 | |
| 227 | return nil |
| 228 | } |
| 229 | |
| 230 | // MarshalBinary interface implementation |
| 231 | func (m *InterfaceCircuitTermination) MarshalBinary() ([]byte, error) { |
| 232 | if m == nil { |
| 233 | return nil, nil |
| 234 | } |
| 235 | return swag.WriteJSON(m) |
| 236 | } |
| 237 | |
| 238 | // UnmarshalBinary interface implementation |
| 239 | func (m *InterfaceCircuitTermination) UnmarshalBinary(b []byte) error { |
| 240 | var res InterfaceCircuitTermination |
| 241 | if err := swag.ReadJSON(b, &res); err != nil { |
| 242 | return err |
| 243 | } |
| 244 | *m = res |
| 245 | return nil |
| 246 | } |