github.com/digitalocean/go-netbox@v0.0.2/netbox/models/writable_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 // WritableTenant writable tenant 34 // 35 // swagger:model WritableTenant 36 type WritableTenant 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 *int64 `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 writable tenant 132 func (m *WritableTenant) 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.validateLastUpdated(formats); err != nil { 144 res = append(res, err) 145 } 146 147 if err := m.validateName(formats); err != nil { 148 res = append(res, err) 149 } 150 151 if err := m.validateSlug(formats); err != nil { 152 res = append(res, err) 153 } 154 155 if err := m.validateTags(formats); err != nil { 156 res = append(res, err) 157 } 158 159 if err := m.validateURL(formats); err != nil { 160 res = append(res, err) 161 } 162 163 if len(res) > 0 { 164 return errors.CompositeValidationError(res...) 165 } 166 return nil 167 } 168 169 func (m *WritableTenant) validateCreated(formats strfmt.Registry) error { 170 if swag.IsZero(m.Created) { // not required 171 return nil 172 } 173 174 if err := validate.FormatOf("created", "body", "date", m.Created.String(), formats); err != nil { 175 return err 176 } 177 178 return nil 179 } 180 181 func (m *WritableTenant) validateDescription(formats strfmt.Registry) error { 182 if swag.IsZero(m.Description) { // not required 183 return nil 184 } 185 186 if err := validate.MaxLength("description", "body", m.Description, 200); err != nil { 187 return err 188 } 189 190 return nil 191 } 192 193 func (m *WritableTenant) validateLastUpdated(formats strfmt.Registry) error { 194 if swag.IsZero(m.LastUpdated) { // not required 195 return nil 196 } 197 198 if err := validate.FormatOf("last_updated", "body", "date-time", m.LastUpdated.String(), formats); err != nil { 199 return err 200 } 201 202 return nil 203 } 204 205 func (m *WritableTenant) validateName(formats strfmt.Registry) error { 206 207 if err := validate.Required("name", "body", m.Name); err != nil { 208 return err 209 } 210 211 if err := validate.MinLength("name", "body", *m.Name, 1); err != nil { 212 return err 213 } 214 215 if err := validate.MaxLength("name", "body", *m.Name, 100); err != nil { 216 return err 217 } 218 219 return nil 220 } 221 222 func (m *WritableTenant) validateSlug(formats strfmt.Registry) error { 223 224 if err := validate.Required("slug", "body", m.Slug); err != nil { 225 return err 226 } 227 228 if err := validate.MinLength("slug", "body", *m.Slug, 1); err != nil { 229 return err 230 } 231 232 if err := validate.MaxLength("slug", "body", *m.Slug, 100); err != nil { 233 return err 234 } 235 236 if err := validate.Pattern("slug", "body", *m.Slug, `^[-a-zA-Z0-9_]+$`); err != nil { 237 return err 238 } 239 240 return nil 241 } 242 243 func (m *WritableTenant) validateTags(formats strfmt.Registry) error { 244 if swag.IsZero(m.Tags) { // not required 245 return nil 246 } 247 248 for i := 0; i < len(m.Tags); i++ { 249 if swag.IsZero(m.Tags[i]) { // not required 250 continue 251 } 252 253 if m.Tags[i] != nil { 254 if err := m.Tags[i].Validate(formats); err != nil { 255 if ve, ok := err.(*errors.Validation); ok { 256 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 257 } else if ce, ok := err.(*errors.CompositeError); ok { 258 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 259 } 260 return err 261 } 262 } 263 264 } 265 266 return nil 267 } 268 269 func (m *WritableTenant) validateURL(formats strfmt.Registry) error { 270 if swag.IsZero(m.URL) { // not required 271 return nil 272 } 273 274 if err := validate.FormatOf("url", "body", "uri", m.URL.String(), formats); err != nil { 275 return err 276 } 277 278 return nil 279 } 280 281 // ContextValidate validate this writable tenant based on the context it is used 282 func (m *WritableTenant) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 283 var res []error 284 285 if err := m.contextValidateCircuitCount(ctx, formats); err != nil { 286 res = append(res, err) 287 } 288 289 if err := m.contextValidateClusterCount(ctx, formats); err != nil { 290 res = append(res, err) 291 } 292 293 if err := m.contextValidateCreated(ctx, formats); err != nil { 294 res = append(res, err) 295 } 296 297 if err := m.contextValidateDeviceCount(ctx, formats); err != nil { 298 res = append(res, err) 299 } 300 301 if err := m.contextValidateDisplay(ctx, formats); err != nil { 302 res = append(res, err) 303 } 304 305 if err := m.contextValidateID(ctx, formats); err != nil { 306 res = append(res, err) 307 } 308 309 if err := m.contextValidateIpaddressCount(ctx, formats); err != nil { 310 res = append(res, err) 311 } 312 313 if err := m.contextValidateLastUpdated(ctx, formats); err != nil { 314 res = append(res, err) 315 } 316 317 if err := m.contextValidatePrefixCount(ctx, formats); err != nil { 318 res = append(res, err) 319 } 320 321 if err := m.contextValidateRackCount(ctx, formats); err != nil { 322 res = append(res, err) 323 } 324 325 if err := m.contextValidateSiteCount(ctx, formats); err != nil { 326 res = append(res, err) 327 } 328 329 if err := m.contextValidateTags(ctx, formats); err != nil { 330 res = append(res, err) 331 } 332 333 if err := m.contextValidateURL(ctx, formats); err != nil { 334 res = append(res, err) 335 } 336 337 if err := m.contextValidateVirtualmachineCount(ctx, formats); err != nil { 338 res = append(res, err) 339 } 340 341 if err := m.contextValidateVlanCount(ctx, formats); err != nil { 342 res = append(res, err) 343 } 344 345 if err := m.contextValidateVrfCount(ctx, formats); err != nil { 346 res = append(res, err) 347 } 348 349 if len(res) > 0 { 350 return errors.CompositeValidationError(res...) 351 } 352 return nil 353 } 354 355 func (m *WritableTenant) contextValidateCircuitCount(ctx context.Context, formats strfmt.Registry) error { 356 357 if err := validate.ReadOnly(ctx, "circuit_count", "body", int64(m.CircuitCount)); err != nil { 358 return err 359 } 360 361 return nil 362 } 363 364 func (m *WritableTenant) contextValidateClusterCount(ctx context.Context, formats strfmt.Registry) error { 365 366 if err := validate.ReadOnly(ctx, "cluster_count", "body", int64(m.ClusterCount)); err != nil { 367 return err 368 } 369 370 return nil 371 } 372 373 func (m *WritableTenant) contextValidateCreated(ctx context.Context, formats strfmt.Registry) error { 374 375 if err := validate.ReadOnly(ctx, "created", "body", strfmt.Date(m.Created)); err != nil { 376 return err 377 } 378 379 return nil 380 } 381 382 func (m *WritableTenant) contextValidateDeviceCount(ctx context.Context, formats strfmt.Registry) error { 383 384 if err := validate.ReadOnly(ctx, "device_count", "body", int64(m.DeviceCount)); err != nil { 385 return err 386 } 387 388 return nil 389 } 390 391 func (m *WritableTenant) contextValidateDisplay(ctx context.Context, formats strfmt.Registry) error { 392 393 if err := validate.ReadOnly(ctx, "display", "body", string(m.Display)); err != nil { 394 return err 395 } 396 397 return nil 398 } 399 400 func (m *WritableTenant) contextValidateID(ctx context.Context, formats strfmt.Registry) error { 401 402 if err := validate.ReadOnly(ctx, "id", "body", int64(m.ID)); err != nil { 403 return err 404 } 405 406 return nil 407 } 408 409 func (m *WritableTenant) contextValidateIpaddressCount(ctx context.Context, formats strfmt.Registry) error { 410 411 if err := validate.ReadOnly(ctx, "ipaddress_count", "body", int64(m.IpaddressCount)); err != nil { 412 return err 413 } 414 415 return nil 416 } 417 418 func (m *WritableTenant) contextValidateLastUpdated(ctx context.Context, formats strfmt.Registry) error { 419 420 if err := validate.ReadOnly(ctx, "last_updated", "body", strfmt.DateTime(m.LastUpdated)); err != nil { 421 return err 422 } 423 424 return nil 425 } 426 427 func (m *WritableTenant) contextValidatePrefixCount(ctx context.Context, formats strfmt.Registry) error { 428 429 if err := validate.ReadOnly(ctx, "prefix_count", "body", int64(m.PrefixCount)); err != nil { 430 return err 431 } 432 433 return nil 434 } 435 436 func (m *WritableTenant) contextValidateRackCount(ctx context.Context, formats strfmt.Registry) error { 437 438 if err := validate.ReadOnly(ctx, "rack_count", "body", int64(m.RackCount)); err != nil { 439 return err 440 } 441 442 return nil 443 } 444 445 func (m *WritableTenant) contextValidateSiteCount(ctx context.Context, formats strfmt.Registry) error { 446 447 if err := validate.ReadOnly(ctx, "site_count", "body", int64(m.SiteCount)); err != nil { 448 return err 449 } 450 451 return nil 452 } 453 454 func (m *WritableTenant) contextValidateTags(ctx context.Context, formats strfmt.Registry) error { 455 456 for i := 0; i < len(m.Tags); i++ { 457 458 if m.Tags[i] != nil { 459 if err := m.Tags[i].ContextValidate(ctx, formats); err != nil { 460 if ve, ok := err.(*errors.Validation); ok { 461 return ve.ValidateName("tags" + "." + strconv.Itoa(i)) 462 } else if ce, ok := err.(*errors.CompositeError); ok { 463 return ce.ValidateName("tags" + "." + strconv.Itoa(i)) 464 } 465 return err 466 } 467 } 468 469 } 470 471 return nil 472 } 473 474 func (m *WritableTenant) contextValidateURL(ctx context.Context, formats strfmt.Registry) error { 475 476 if err := validate.ReadOnly(ctx, "url", "body", strfmt.URI(m.URL)); err != nil { 477 return err 478 } 479 480 return nil 481 } 482 483 func (m *WritableTenant) contextValidateVirtualmachineCount(ctx context.Context, formats strfmt.Registry) error { 484 485 if err := validate.ReadOnly(ctx, "virtualmachine_count", "body", int64(m.VirtualmachineCount)); err != nil { 486 return err 487 } 488 489 return nil 490 } 491 492 func (m *WritableTenant) contextValidateVlanCount(ctx context.Context, formats strfmt.Registry) error { 493 494 if err := validate.ReadOnly(ctx, "vlan_count", "body", int64(m.VlanCount)); err != nil { 495 return err 496 } 497 498 return nil 499 } 500 501 func (m *WritableTenant) contextValidateVrfCount(ctx context.Context, formats strfmt.Registry) error { 502 503 if err := validate.ReadOnly(ctx, "vrf_count", "body", int64(m.VrfCount)); err != nil { 504 return err 505 } 506 507 return nil 508 } 509 510 // MarshalBinary interface implementation 511 func (m *WritableTenant) MarshalBinary() ([]byte, error) { 512 if m == nil { 513 return nil, nil 514 } 515 return swag.WriteJSON(m) 516 } 517 518 // UnmarshalBinary interface implementation 519 func (m *WritableTenant) UnmarshalBinary(b []byte) error { 520 var res WritableTenant 521 if err := swag.ReadJSON(b, &res); err != nil { 522 return err 523 } 524 *m = res 525 return nil 526 }