blob: c3c5953c1f1c8f36324760823825408b492f48c8 [file] [log] [blame]
Serge Bazanskicc25bdf2018-10-25 14:02:58 +02001// 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
17package 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
22import (
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// Circuit circuit
31// swagger:model Circuit
32type Circuit struct {
33
34 // Circuit ID
35 // Required: true
36 // Max Length: 50
37 Cid *string `json:"cid"`
38
39 // Comments
40 Comments string `json:"comments,omitempty"`
41
42 // Commit rate (Kbps)
43 // Maximum: 2.147483647e+09
44 // Minimum: 0
45 CommitRate *int64 `json:"commit_rate,omitempty"`
46
47 // Created
48 // Read Only: true
49 Created strfmt.Date `json:"created,omitempty"`
50
51 // Custom fields
52 CustomFields interface{} `json:"custom_fields,omitempty"`
53
54 // Description
55 // Max Length: 100
56 Description string `json:"description,omitempty"`
57
58 // ID
59 // Read Only: true
60 ID int64 `json:"id,omitempty"`
61
62 // Date installed
63 InstallDate strfmt.Date `json:"install_date,omitempty"`
64
65 // Last updated
66 // Read Only: true
67 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"`
68
69 // provider
70 // Required: true
71 Provider *NestedProvider `json:"provider"`
72
73 // status
74 // Required: true
75 Status *CircuitStatus `json:"status"`
76
77 // tenant
78 // Required: true
79 Tenant *NestedTenant `json:"tenant"`
80
81 // type
82 // Required: true
83 Type *NestedCircuitType `json:"type"`
84}
85
86// Validate validates this circuit
87func (m *Circuit) Validate(formats strfmt.Registry) error {
88 var res []error
89
90 if err := m.validateCid(formats); err != nil {
91 // prop
92 res = append(res, err)
93 }
94
95 if err := m.validateCommitRate(formats); err != nil {
96 // prop
97 res = append(res, err)
98 }
99
100 if err := m.validateDescription(formats); err != nil {
101 // prop
102 res = append(res, err)
103 }
104
105 if err := m.validateProvider(formats); err != nil {
106 // prop
107 res = append(res, err)
108 }
109
110 if err := m.validateStatus(formats); err != nil {
111 // prop
112 res = append(res, err)
113 }
114
115 if err := m.validateTenant(formats); err != nil {
116 // prop
117 res = append(res, err)
118 }
119
120 if err := m.validateType(formats); err != nil {
121 // prop
122 res = append(res, err)
123 }
124
125 if len(res) > 0 {
126 return errors.CompositeValidationError(res...)
127 }
128 return nil
129}
130
131func (m *Circuit) validateCid(formats strfmt.Registry) error {
132
133 if err := validate.Required("cid", "body", m.Cid); err != nil {
134 return err
135 }
136
137 if err := validate.MaxLength("cid", "body", string(*m.Cid), 50); err != nil {
138 return err
139 }
140
141 return nil
142}
143
144func (m *Circuit) validateCommitRate(formats strfmt.Registry) error {
145
146 if swag.IsZero(m.CommitRate) { // not required
147 return nil
148 }
149
150 if err := validate.MinimumInt("commit_rate", "body", int64(*m.CommitRate), 0, false); err != nil {
151 return err
152 }
153
154 if err := validate.MaximumInt("commit_rate", "body", int64(*m.CommitRate), 2.147483647e+09, false); err != nil {
155 return err
156 }
157
158 return nil
159}
160
161func (m *Circuit) validateDescription(formats strfmt.Registry) error {
162
163 if swag.IsZero(m.Description) { // not required
164 return nil
165 }
166
167 if err := validate.MaxLength("description", "body", string(m.Description), 100); err != nil {
168 return err
169 }
170
171 return nil
172}
173
174func (m *Circuit) validateProvider(formats strfmt.Registry) error {
175
176 if err := validate.Required("provider", "body", m.Provider); err != nil {
177 return err
178 }
179
180 if m.Provider != nil {
181
182 if err := m.Provider.Validate(formats); err != nil {
183 if ve, ok := err.(*errors.Validation); ok {
184 return ve.ValidateName("provider")
185 }
186 return err
187 }
188 }
189
190 return nil
191}
192
193func (m *Circuit) validateStatus(formats strfmt.Registry) error {
194
195 if err := validate.Required("status", "body", m.Status); err != nil {
196 return err
197 }
198
199 if m.Status != nil {
200
201 if err := m.Status.Validate(formats); err != nil {
202 if ve, ok := err.(*errors.Validation); ok {
203 return ve.ValidateName("status")
204 }
205 return err
206 }
207 }
208
209 return nil
210}
211
212func (m *Circuit) validateTenant(formats strfmt.Registry) error {
213
214 if err := validate.Required("tenant", "body", m.Tenant); err != nil {
215 return err
216 }
217
218 if m.Tenant != nil {
219
220 if err := m.Tenant.Validate(formats); err != nil {
221 if ve, ok := err.(*errors.Validation); ok {
222 return ve.ValidateName("tenant")
223 }
224 return err
225 }
226 }
227
228 return nil
229}
230
231func (m *Circuit) validateType(formats strfmt.Registry) error {
232
233 if err := validate.Required("type", "body", m.Type); err != nil {
234 return err
235 }
236
237 if m.Type != nil {
238
239 if err := m.Type.Validate(formats); err != nil {
240 if ve, ok := err.(*errors.Validation); ok {
241 return ve.ValidateName("type")
242 }
243 return err
244 }
245 }
246
247 return nil
248}
249
250// MarshalBinary interface implementation
251func (m *Circuit) MarshalBinary() ([]byte, error) {
252 if m == nil {
253 return nil, nil
254 }
255 return swag.WriteJSON(m)
256}
257
258// UnmarshalBinary interface implementation
259func (m *Circuit) UnmarshalBinary(b []byte) error {
260 var res Circuit
261 if err := swag.ReadJSON(b, &res); err != nil {
262 return err
263 }
264 *m = res
265 return nil
266}