github.com/digitalocean/go-netbox@v0.0.2/netbox/models/writable_v_r_f.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 // Copyright 2020 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 18 package models 19 20 // This file was generated by the swagger tool. 21 // Editing this file might prove futile when you re-run the swagger generate command 22 23 import ( 24 "context" 25 "strconv" 26 27 "github.com/go-openapi/errors" 28 "github.com/go-openapi/strfmt" 29 "github.com/go-openapi/swag" 30 "github.com/go-openapi/validate" 31 ) 32 33 // WritableVRF writable v r f 34 // 35 // swagger:model WritableVRF 36 type WritableVRF struct { 37 38 // Created 39 // Read Only: true 40 // Format: date 41 Created strfmt.Date `json:"created,omitempty"` 42 43 // Custom fields 44 CustomFields interface{} `json:"custom_fields,omitempty"` 45 46 // Description 47 // Max Length: 200 48 Description string `json:"description,omitempty"` 49 50 // Display 51 // Read Only: true 52 Display string `json:"display,omitempty"` 53 54 // Display name 55 // Read Only: true 56 DisplayName string `json:"display_name,omitempty"` 57 58 // Enforce unique space 59 // 60 // Prevent duplicate prefixes/IP addresses within this VRF 61 EnforceUnique bool `json:"enforce_unique,omitempty"` 62 63 // export targets 64 // Unique: true 65 ExportTargets []int64 `json:"export_targets"` 66 67 // Id 68 // Read Only: true 69 ID int64 `json:"id,omitempty"` 70 71 // import targets 72 // Unique: true 73 ImportTargets []int64 `json:"import_targets"` 74 75 // Ipaddress count 76 // Read Only: true 77 IpaddressCount int64 `json:"ipaddress_count,omitempty"` 78 79 // Last updated 80 // Read Only: true 81 // Format: date-time 82 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"` 83 84 // Name 85 // Required: true 86 // Max Length: 100 87 // Min Length: 1 88 Name *string `json:"name"` 89 90 // Prefix count 91 // Read Only: true 92 PrefixCount int64 `json:"prefix_count,omitempty"` 93 94 // Route distinguisher 95 // 96 // Unique route distinguisher (as defined in RFC 4364) 97 // Max Length: 21 98 Rd *string `json:"rd,omitempty"` 99 100 // tags 101 Tags []*NestedTag `json:"tags"` 102 103 // Tenant 104 Tenant *int64 `json:"tenant,omitempty"` 105 106 // Url 107 // Read Only: true 108 // Format: uri 109 URL strfmt.URI `json:"url,omitempty"` 110 } 111 112 // Validate validates this writable v r f 113 func (m *WritableVRF) Validate(formats strfmt.Registry) error { 114 var res []error 115 116 if err := m.validateCreated(formats); err != nil { 117 res = append(res, err) 118 } 119 120 if err := m.validateDescription(formats); err != nil { 121 res = append(res, err) 122 } 123 124 if err := m.validateExportTargets(formats); err != nil { 125 res = append(res, err) 126 } 127 128 if err := m.validateImportTargets(formats); err != nil { 129 res = append(res, err) 130 } 131 132 if err := m.validateLastUpdated(formats); err != nil { 133 res = append(res, err) 134 } 135 136 if err := m.validateName(formats); err != nil { 137 res = append(res, err) 138 } 139 140 if err := m.validateRd(formats); err != nil { 141 res = append(res, err) 142 } 143 144 if err := m.validateTags(formats); err != nil { 145 res = append(res, err) 146 } 147 148 if err := m.validateURL(formats); err != nil { 149 res = append(res, err) 150 } 151 152 if len(res) > 0 { 153 return errors.CompositeValidationError(res...) 154 } 155 return nil 156 } 157 158 func (m *WritableVRF) validateCreated(formats strfmt.Registry) error { 159 if swag.IsZero(m.Created) { // not required 160 return nil 161 } 162 163 if err := validate.FormatOf("created", "body", "date", m.Created.String(), formats); err != nil { 164 return err 165 } 166 167 return nil 168 } 169 170 func (m *WritableVRF) validateDescription(formats strfmt.Registry) error { 171 if swag.IsZero(m.Description) { // not required 172 return nil 173 } 174 175 if err := validate.MaxLength("description", "body", m.Description, 200); err != nil { 176 return err 177 } 178 179 return nil 180 } 181 182 func (m *WritableVRF) validateExportTargets(formats strfmt.Registry) error { 183 if swag.IsZero(m.ExportTargets) { // not required 184 return nil 185 } 186 187 if err := validate.UniqueItems("export_targets", "body", m.ExportTargets); err != nil { 188 return err 189 } 190 191 return nil 192 } 193 194 func (m *WritableVRF) validateImportTargets(formats strfmt.Registry) error { 195 if swag.IsZero(m.ImportTargets) { // not required 196 return nil 197 } 198 199 if err := validate.UniqueItems("import_targets", "body", m.ImportTargets); err != nil { 200 return err 201 } 202 203 return nil 204 } 205 206 func (m *WritableVRF) validateLastUpdated(formats strfmt.Registry) error { 207 if swag.IsZero(m.LastUpdated) { // not required 208 return nil 209 } 210 211 if err := validate.FormatOf("last_updated", "body", "date-time", m.LastUpdated.String(), formats); err != nil { 212 return err 213 } 214 215 return nil 216 } 217 218 func (m *WritableVRF) validateName(formats strfmt.Registry) error { 219 220 if err := validate.Required("name", "body", m.Name); err != nil { 221 return err 222 } 223 224 if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { 225 return err 226 } 227 228 if err := validate.MaxLength("name", "body", *m.Name, 100); err != nil { 229 return err 230 } 231 232 return nil 233 } 234 235 func (m *WritableVRF) validateRd(formats strfmt.Registry) error { 236 if swag.IsZero(m.Rd) { // not required 237 return nil 238 } 239 240 if err := validate.MaxLength("rd", "body", *m.Rd, 21); err != nil { 241 return err 242 } 243 244 return nil 245 } 246 247 func (m *WritableVRF) validateTags(formats strfmt.Registry) error { 248 if swag.IsZero(m.Tags) { // not required 249 return nil 250 } 251 252 for i := 0; i < len(m.Tags); i++ { 253 if swag.IsZero(m.Tags[i]) { // not required 254 continue 255 } 256 257 if m.Tags[i] != nil { 258 if err := m.Tags[i].Validate(formats); err != nil { 259 if ve, ok := err.(*errors.Validation); ok { 260 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 261 } else if ce, ok := err.(*errors.CompositeError); ok { 262 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 263 } 264 return err 265 } 266 } 267 268 } 269 270 return nil 271 } 272 273 func (m *WritableVRF) validateURL(formats strfmt.Registry) error { 274 if swag.IsZero(m.URL) { // not required 275 return nil 276 } 277 278 if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { 279 return err 280 } 281 282 return nil 283 } 284 285 // ContextValidate validate this writable v r f based on the context it is used 286 func (m *WritableVRF) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 287 var res []error 288 289 if err := m.contextValidateCreated(ctx, formats); err != nil { 290 res = append(res, err) 291 } 292 293 if err := m.contextValidateDisplay(ctx, formats); err != nil { 294 res = append(res, err) 295 } 296 297 if err := m.contextValidateDisplayName(ctx, formats); err != nil { 298 res = append(res, err) 299 } 300 301 if err := m.contextValidateID(ctx, formats); err != nil { 302 res = append(res, err) 303 } 304 305 if err := m.contextValidateIpaddressCount(ctx, formats); err != nil { 306 res = append(res, err) 307 } 308 309 if err := m.contextValidateLastUpdated(ctx, formats); err != nil { 310 res = append(res, err) 311 } 312 313 if err := m.contextValidatePrefixCount(ctx, formats); err != nil { 314 res = append(res, err) 315 } 316 317 if err := m.contextValidateTags(ctx, formats); err != nil { 318 res = append(res, err) 319 } 320 321 if err := m.contextValidateURL(ctx, formats); err != nil { 322 res = append(res, err) 323 } 324 325 if len(res) > 0 { 326 return errors.CompositeValidationError(res...) 327 } 328 return nil 329 } 330 331 func (m *WritableVRF) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error { 332 333 if err := validate.ReadOnly(ctx, "created", "body", strfmt.Date(m.Created)); err != nil { 334 return err 335 } 336 337 return nil 338 } 339 340 func (m *WritableVRF) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error { 341 342 if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil { 343 return err 344 } 345 346 return nil 347 } 348 349 func (m *WritableVRF) contextValidateDisplayName(ctx context.Context, formats strfmt.Registry) error { 350 351 if err := validate.ReadOnly(ctx, "display_name", "body", string(m.DisplayName)); err != nil { 352 return err 353 } 354 355 return nil 356 } 357 358 func (m *WritableVRF) contextValidateID(ctx context.Context, formats strfmt.Registry) error { 359 360 if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil { 361 return err 362 } 363 364 return nil 365 } 366 367 func (m *WritableVRF) contextValidateIpaddressCount(ctx context.Context, formats strfmt.Registry) error { 368 369 if err := validate.ReadOnly(ctx, "ipaddress_count", "body", int64(m.IpaddressCount)); err != nil { 370 return err 371 } 372 373 return nil 374 } 375 376 func (m *WritableVRF) contextValidateLastUpdated(ctx context.Context, formats strfmt.Registry) error { 377 378 if err := validate.ReadOnly(ctx, "last_updated", "body", strfmt.DateTime(m.LastUpdated)); err != nil { 379 return err 380 } 381 382 return nil 383 } 384 385 func (m *WritableVRF) contextValidatePrefixCount(ctx context.Context, formats strfmt.Registry) error { 386 387 if err := validate.ReadOnly(ctx, "prefix_count", "body", int64(m.PrefixCount)); err != nil { 388 return err 389 } 390 391 return nil 392 } 393 394 func (m *WritableVRF) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { 395 396 for i := 0; i < len(m.Tags); i++ { 397 398 if m.Tags[i] != nil { 399 if err := m.Tags[i].ContextValidate(ctx, formats); err != nil { 400 if ve, ok := err.(*errors.Validation); ok { 401 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 402 } else if ce, ok := err.(*errors.CompositeError); ok { 403 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 404 } 405 return err 406 } 407 } 408 409 } 410 411 return nil 412 } 413 414 func (m *WritableVRF) contextValidateURL(ctx context.Context, formats strfmt.Registry) error { 415 416 if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil { 417 return err 418 } 419 420 return nil 421 } 422 423 // MarshalBinary interface implementation 424 func (m *WritableVRF) MarshalBinary() ([]byte, error) { 425 if m == nil { 426 return nil, nil 427 } 428 return swag.WriteJSON(m) 429 } 430 431 // UnmarshalBinary interface implementation 432 func (m *WritableVRF) UnmarshalBinary(b []byte) error { 433 var res WritableVRF 434 if err := swag.ReadJSON(b, &res); err != nil { 435 return err 436 } 437 *m = res 438 return nil 439 }