github.com/digitalocean/go-netbox@v0.0.2/netbox/models/tenant.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 // Tenant tenant 34 // 35 // swagger:model Tenant 36 type Tenant struct { 37 38 // Circuit count 39 // Read Only: true 40 CircuitCount int64 `json:"circuit_count,omitempty"` 41 42 // Cluster count 43 // Read Only: true 44 ClusterCount int64 `json:"cluster_count,omitempty"` 45 46 // Comments 47 Comments string `json:"comments,omitempty"` 48 49 // Created 50 // Read Only: true 51 // Format: date 52 Created strfmt.Date `json:"created,omitempty"` 53 54 // Custom fields 55 CustomFields interface{} `json:"custom_fields,omitempty"` 56 57 // Description 58 // Max Length: 200 59 Description string `json:"description,omitempty"` 60 61 // Device count 62 // Read Only: true 63 DeviceCount int64 `json:"device_count,omitempty"` 64 65 // Display 66 // Read Only: true 67 Display string `json:"display,omitempty"` 68 69 // group 70 Group *NestedTenantGroup `json:"group,omitempty"` 71 72 // Id 73 // Read Only: true 74 ID int64 `json:"id,omitempty"` 75 76 // Ipaddress count 77 // Read Only: true 78 IpaddressCount int64 `json:"ipaddress_count,omitempty"` 79 80 // Last updated 81 // Read Only: true 82 // Format: date-time 83 LastUpdated strfmt.DateTime `json:"last_updated,omitempty"` 84 85 // Name 86 // Required: true 87 // Max Length: 100 88 // Min Length: 1 89 Name *string `json:"name"` 90 91 // Prefix count 92 // Read Only: true 93 PrefixCount int64 `json:"prefix_count,omitempty"` 94 95 // Rack count 96 // Read Only: true 97 RackCount int64 `json:"rack_count,omitempty"` 98 99 // Site count 100 // Read Only: true 101 SiteCount int64 `json:"site_count,omitempty"` 102 103 // Slug 104 // Required: true 105 // Max Length: 100 106 // Min Length: 1 107 // Pattern: ^[-a-zA-Z0-9_]+$ 108 Slug *string `json:"slug"` 109 110 // tags 111 Tags []*NestedTag `json:"tags"` 112 113 // Url 114 // Read Only: true 115 // Format: uri 116 URL strfmt.URI `json:"url,omitempty"` 117 118 // Virtualmachine count 119 // Read Only: true 120 VirtualmachineCount int64 `json:"virtualmachine_count,omitempty"` 121 122 // Vlan count 123 // Read Only: true 124 VlanCount int64 `json:"vlan_count,omitempty"` 125 126 // Vrf count 127 // Read Only: true 128 VrfCount int64 `json:"vrf_count,omitempty"` 129 } 130 131 // Validate validates this tenant 132 func (m *Tenant) Validate(formats strfmt.Registry) error { 133 var res []error 134 135 if err := m.validateCreated(formats); err != nil { 136 res = append(res, err) 137 } 138 139 if err := m.validateDescription(formats); err != nil { 140 res = append(res, err) 141 } 142 143 if err := m.validateGroup(formats); err != nil { 144 res = append(res, err) 145 } 146 147 if err := m.validateLastUpdated(formats); err != nil { 148 res = append(res, err) 149 } 150 151 if err := m.validateName(formats); err != nil { 152 res = append(res, err) 153 } 154 155 if err := m.validateSlug(formats); err != nil { 156 res = append(res, err) 157 } 158 159 if err := m.validateTags(formats); err != nil { 160 res = append(res, err) 161 } 162 163 if err := m.validateURL(formats); err != nil { 164 res = append(res, err) 165 } 166 167 if len(res) > 0 { 168 return errors.CompositeValidationError(res...) 169 } 170 return nil 171 } 172 173 func (m *Tenant) validateCreated(formats strfmt.Registry) error { 174 if swag.IsZero(m.Created) { // not required 175 return nil 176 } 177 178 if err := validate.FormatOf("created", "body", "date", m.Created.String(), formats); err != nil { 179 return err 180 } 181 182 return nil 183 } 184 185 func (m *Tenant) validateDescription(formats strfmt.Registry) error { 186 if swag.IsZero(m.Description) { // not required 187 return nil 188 } 189 190 if err := validate.MaxLength("description", "body", m.Description, 200); err != nil { 191 return err 192 } 193 194 return nil 195 } 196 197 func (m *Tenant) validateGroup(formats strfmt.Registry) error { 198 if swag.IsZero(m.Group) { // not required 199 return nil 200 } 201 202 if m.Group != nil { 203 if err := m.Group.Validate(formats); err != nil { 204 if ve, ok := err.(*errors.Validation); ok { 205 return ve.ValidateName("group") 206 } else if ce, ok := err.(*errors.CompositeError); ok { 207 return ce.ValidateName("group") 208 } 209 return err 210 } 211 } 212 213 return nil 214 } 215 216 func (m *Tenant) validateLastUpdated(formats strfmt.Registry) error { 217 if swag.IsZero(m.LastUpdated) { // not required 218 return nil 219 } 220 221 if err := validate.FormatOf("last_updated", "body", "date-time", m.LastUpdated.String(), formats); err != nil { 222 return err 223 } 224 225 return nil 226 } 227 228 func (m *Tenant) validateName(formats strfmt.Registry) error { 229 230 if err := validate.Required("name", "body", m.Name); err != nil { 231 return err 232 } 233 234 if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { 235 return err 236 } 237 238 if err := validate.MaxLength("name", "body", *m.Name, 100); err != nil { 239 return err 240 } 241 242 return nil 243 } 244 245 func (m *Tenant) validateSlug(formats strfmt.Registry) error { 246 247 if err := validate.Required("slug", "body", m.Slug); err != nil { 248 return err 249 } 250 251 if err := validate.MinLength("slug", "body", *m.Slug, 1); err != nil { 252 return err 253 } 254 255 if err := validate.MaxLength("slug", "body", *m.Slug, 100); err != nil { 256 return err 257 } 258 259 if err := validate.Pattern("slug", "body", *m.Slug, `^[-a-zA-Z0-9_]+$`); err != nil { 260 return err 261 } 262 263 return nil 264 } 265 266 func (m *Tenant) validateTags(formats strfmt.Registry) error { 267 if swag.IsZero(m.Tags) { // not required 268 return nil 269 } 270 271 for i := 0; i < len(m.Tags); i++ { 272 if swag.IsZero(m.Tags[i]) { // not required 273 continue 274 } 275 276 if m.Tags[i] != nil { 277 if err := m.Tags[i].Validate(formats); err != nil { 278 if ve, ok := err.(*errors.Validation); ok { 279 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 280 } else if ce, ok := err.(*errors.CompositeError); ok { 281 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 282 } 283 return err 284 } 285 } 286 287 } 288 289 return nil 290 } 291 292 func (m *Tenant) validateURL(formats strfmt.Registry) error { 293 if swag.IsZero(m.URL) { // not required 294 return nil 295 } 296 297 if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { 298 return err 299 } 300 301 return nil 302 } 303 304 // ContextValidate validate this tenant based on the context it is used 305 func (m *Tenant) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 306 var res []error 307 308 if err := m.contextValidateCircuitCount(ctx, formats); err != nil { 309 res = append(res, err) 310 } 311 312 if err := m.contextValidateClusterCount(ctx, formats); err != nil { 313 res = append(res, err) 314 } 315 316 if err := m.contextValidateCreated(ctx, formats); err != nil { 317 res = append(res, err) 318 } 319 320 if err := m.contextValidateDeviceCount(ctx, formats); err != nil { 321 res = append(res, err) 322 } 323 324 if err := m.contextValidateDisplay(ctx, formats); err != nil { 325 res = append(res, err) 326 } 327 328 if err := m.contextValidateGroup(ctx, formats); err != nil { 329 res = append(res, err) 330 } 331 332 if err := m.contextValidateID(ctx, formats); err != nil { 333 res = append(res, err) 334 } 335 336 if err := m.contextValidateIpaddressCount(ctx, formats); err != nil { 337 res = append(res, err) 338 } 339 340 if err := m.contextValidateLastUpdated(ctx, formats); err != nil { 341 res = append(res, err) 342 } 343 344 if err := m.contextValidatePrefixCount(ctx, formats); err != nil { 345 res = append(res, err) 346 } 347 348 if err := m.contextValidateRackCount(ctx, formats); err != nil { 349 res = append(res, err) 350 } 351 352 if err := m.contextValidateSiteCount(ctx, formats); err != nil { 353 res = append(res, err) 354 } 355 356 if err := m.contextValidateTags(ctx, formats); err != nil { 357 res = append(res, err) 358 } 359 360 if err := m.contextValidateURL(ctx, formats); err != nil { 361 res = append(res, err) 362 } 363 364 if err := m.contextValidateVirtualmachineCount(ctx, formats); err != nil { 365 res = append(res, err) 366 } 367 368 if err := m.contextValidateVlanCount(ctx, formats); err != nil { 369 res = append(res, err) 370 } 371 372 if err := m.contextValidateVrfCount(ctx, formats); err != nil { 373 res = append(res, err) 374 } 375 376 if len(res) > 0 { 377 return errors.CompositeValidationError(res...) 378 } 379 return nil 380 } 381 382 func (m *Tenant) contextValidateCircuitCount(ctx context.Context, formats strfmt.Registry) error { 383 384 if err := validate.ReadOnly(ctx, "circuit_count", "body", int64(m.CircuitCount)); err != nil { 385 return err 386 } 387 388 return nil 389 } 390 391 func (m *Tenant) contextValidateClusterCount(ctx context.Context, formats strfmt.Registry) error { 392 393 if err := validate.ReadOnly(ctx, "cluster_count", "body", int64(m.ClusterCount)); err != nil { 394 return err 395 } 396 397 return nil 398 } 399 400 func (m *Tenant) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error { 401 402 if err := validate.ReadOnly(ctx, "created", "body", strfmt.Date(m.Created)); err != nil { 403 return err 404 } 405 406 return nil 407 } 408 409 func (m *Tenant) contextValidateDeviceCount(ctx context.Context, formats strfmt.Registry) error { 410 411 if err := validate.ReadOnly(ctx, "device_count", "body", int64(m.DeviceCount)); err != nil { 412 return err 413 } 414 415 return nil 416 } 417 418 func (m *Tenant) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error { 419 420 if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil { 421 return err 422 } 423 424 return nil 425 } 426 427 func (m *Tenant) contextValidateGroup(ctx context.Context, formats strfmt.Registry) error { 428 429 if m.Group != nil { 430 if err := m.Group.ContextValidate(ctx, formats); err != nil { 431 if ve, ok := err.(*errors.Validation); ok { 432 return ve.ValidateName("group") 433 } else if ce, ok := err.(*errors.CompositeError); ok { 434 return ce.ValidateName("group") 435 } 436 return err 437 } 438 } 439 440 return nil 441 } 442 443 func (m *Tenant) contextValidateID(ctx context.Context, formats strfmt.Registry) error { 444 445 if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil { 446 return err 447 } 448 449 return nil 450 } 451 452 func (m *Tenant) contextValidateIpaddressCount(ctx context.Context, formats strfmt.Registry) error { 453 454 if err := validate.ReadOnly(ctx, "ipaddress_count", "body", int64(m.IpaddressCount)); err != nil { 455 return err 456 } 457 458 return nil 459 } 460 461 func (m *Tenant) contextValidateLastUpdated(ctx context.Context, formats strfmt.Registry) error { 462 463 if err := validate.ReadOnly(ctx, "last_updated", "body", strfmt.DateTime(m.LastUpdated)); err != nil { 464 return err 465 } 466 467 return nil 468 } 469 470 func (m *Tenant) contextValidatePrefixCount(ctx context.Context, formats strfmt.Registry) error { 471 472 if err := validate.ReadOnly(ctx, "prefix_count", "body", int64(m.PrefixCount)); err != nil { 473 return err 474 } 475 476 return nil 477 } 478 479 func (m *Tenant) contextValidateRackCount(ctx context.Context, formats strfmt.Registry) error { 480 481 if err := validate.ReadOnly(ctx, "rack_count", "body", int64(m.RackCount)); err != nil { 482 return err 483 } 484 485 return nil 486 } 487 488 func (m *Tenant) contextValidateSiteCount(ctx context.Context, formats strfmt.Registry) error { 489 490 if err := validate.ReadOnly(ctx, "site_count", "body", int64(m.SiteCount)); err != nil { 491 return err 492 } 493 494 return nil 495 } 496 497 func (m *Tenant) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { 498 499 for i := 0; i < len(m.Tags); i++ { 500 501 if m.Tags[i] != nil { 502 if err := m.Tags[i].ContextValidate(ctx, formats); err != nil { 503 if ve, ok := err.(*errors.Validation); ok { 504 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 505 } else if ce, ok := err.(*errors.CompositeError); ok { 506 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 507 } 508 return err 509 } 510 } 511 512 } 513 514 return nil 515 } 516 517 func (m *Tenant) contextValidateURL(ctx context.Context, formats strfmt.Registry) error { 518 519 if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil { 520 return err 521 } 522 523 return nil 524 } 525 526 func (m *Tenant) contextValidateVirtualmachineCount(ctx context.Context, formats strfmt.Registry) error { 527 528 if err := validate.ReadOnly(ctx, "virtualmachine_count", "body", int64(m.VirtualmachineCount)); err != nil { 529 return err 530 } 531 532 return nil 533 } 534 535 func (m *Tenant) contextValidateVlanCount(ctx context.Context, formats strfmt.Registry) error { 536 537 if err := validate.ReadOnly(ctx, "vlan_count", "body", int64(m.VlanCount)); err != nil { 538 return err 539 } 540 541 return nil 542 } 543 544 func (m *Tenant) contextValidateVrfCount(ctx context.Context, formats strfmt.Registry) error { 545 546 if err := validate.ReadOnly(ctx, "vrf_count", "body", int64(m.VrfCount)); err != nil { 547 return err 548 } 549 550 return nil 551 } 552 553 // MarshalBinary interface implementation 554 func (m *Tenant) MarshalBinary() ([]byte, error) { 555 if m == nil { 556 return nil, nil 557 } 558 return swag.WriteJSON(m) 559 } 560 561 // UnmarshalBinary interface implementation 562 func (m *Tenant) UnmarshalBinary(b []byte) error { 563 var res Tenant 564 if err := swag.ReadJSON(b, &res); err != nil { 565 return err 566 } 567 *m = res 568 return nil 569 }