github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/inventory/inventory_models/platform.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package inventory_models 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 "context" 10 "strconv" 11 12 "github.com/go-openapi/errors" 13 "github.com/go-openapi/strfmt" 14 "github.com/go-openapi/swag" 15 "github.com/go-openapi/validate" 16 ) 17 18 // Platform Platform 19 // 20 // A platform upon which a build can be built. 21 // 22 // swagger:model platform 23 type Platform struct { 24 25 // cpu architecture 26 // Required: true 27 CPUArchitecture *CPUArchitecture `json:"cpu_architecture"` 28 29 // cpu extensions 30 CPUExtensions []*CPUExtension `json:"cpu_extensions"` 31 32 // The date and time this platform was created. 33 // Required: true 34 // Format: date-time 35 CreationTimestamp *strfmt.DateTime `json:"creation_timestamp"` 36 37 // display name 38 // Required: true 39 DisplayName *string `json:"display_name"` 40 41 // The last day on which this platform will be supported. Can be omitted if no last day has yet been determined. 42 // Format: date 43 EndOfSupportDate *strfmt.Date `json:"end_of_support_date,omitempty"` 44 45 // gpu architecture 46 GpuArchitecture *GpuArchitecture `json:"gpu_architecture,omitempty"` 47 48 // images 49 // Required: true 50 Images []*Image `json:"images"` 51 52 // If true, the platform should be shown to the user as a selectable platform for an order. If false, the platform should be hidden from the user. 53 IsUserVisible *bool `json:"is_user_visible,omitempty"` 54 55 // kernel 56 // Required: true 57 Kernel *Kernel `json:"kernel"` 58 59 // kernel version 60 // Required: true 61 KernelVersion *KernelVersion `json:"kernel_version"` 62 63 // libc 64 Libc *Libc `json:"libc,omitempty"` 65 66 // libc version 67 LibcVersion *LibcVersion `json:"libc_version,omitempty"` 68 69 // links 70 // Required: true 71 Links *SelfLink `json:"links"` 72 73 // operating system 74 // Required: true 75 OperatingSystem *OperatingSystem `json:"operating_system"` 76 77 // operating system version 78 // Required: true 79 OperatingSystemVersion *OperatingSystemVersion `json:"operating_system_version"` 80 81 // platform id 82 // Required: true 83 // Format: uuid 84 PlatformID *strfmt.UUID `json:"platform_id"` 85 } 86 87 // Validate validates this platform 88 func (m *Platform) Validate(formats strfmt.Registry) error { 89 var res []error 90 91 if err := m.validateCPUArchitecture(formats); err != nil { 92 res = append(res, err) 93 } 94 95 if err := m.validateCPUExtensions(formats); err != nil { 96 res = append(res, err) 97 } 98 99 if err := m.validateCreationTimestamp(formats); err != nil { 100 res = append(res, err) 101 } 102 103 if err := m.validateDisplayName(formats); err != nil { 104 res = append(res, err) 105 } 106 107 if err := m.validateEndOfSupportDate(formats); err != nil { 108 res = append(res, err) 109 } 110 111 if err := m.validateGpuArchitecture(formats); err != nil { 112 res = append(res, err) 113 } 114 115 if err := m.validateImages(formats); err != nil { 116 res = append(res, err) 117 } 118 119 if err := m.validateKernel(formats); err != nil { 120 res = append(res, err) 121 } 122 123 if err := m.validateKernelVersion(formats); err != nil { 124 res = append(res, err) 125 } 126 127 if err := m.validateLibc(formats); err != nil { 128 res = append(res, err) 129 } 130 131 if err := m.validateLibcVersion(formats); err != nil { 132 res = append(res, err) 133 } 134 135 if err := m.validateLinks(formats); err != nil { 136 res = append(res, err) 137 } 138 139 if err := m.validateOperatingSystem(formats); err != nil { 140 res = append(res, err) 141 } 142 143 if err := m.validateOperatingSystemVersion(formats); err != nil { 144 res = append(res, err) 145 } 146 147 if err := m.validatePlatformID(formats); err != nil { 148 res = append(res, err) 149 } 150 151 if len(res) > 0 { 152 return errors.CompositeValidationError(res...) 153 } 154 return nil 155 } 156 157 func (m *Platform) validateCPUArchitecture(formats strfmt.Registry) error { 158 159 if err := validate.Required("cpu_architecture", "body", m.CPUArchitecture); err != nil { 160 return err 161 } 162 163 if m.CPUArchitecture != nil { 164 if err := m.CPUArchitecture.Validate(formats); err != nil { 165 if ve, ok := err.(*errors.Validation); ok { 166 return ve.ValidateName("cpu_architecture") 167 } 168 return err 169 } 170 } 171 172 return nil 173 } 174 175 func (m *Platform) validateCPUExtensions(formats strfmt.Registry) error { 176 if swag.IsZero(m.CPUExtensions) { // not required 177 return nil 178 } 179 180 for i := 0; i < len(m.CPUExtensions); i++ { 181 if swag.IsZero(m.CPUExtensions[i]) { // not required 182 continue 183 } 184 185 if m.CPUExtensions[i] != nil { 186 if err := m.CPUExtensions[i].Validate(formats); err != nil { 187 if ve, ok := err.(*errors.Validation); ok { 188 return ve.ValidateName("cpu_extensions" + "." + strconv.Itoa(i)) 189 } 190 return err 191 } 192 } 193 194 } 195 196 return nil 197 } 198 199 func (m *Platform) validateCreationTimestamp(formats strfmt.Registry) error { 200 201 if err := validate.Required("creation_timestamp", "body", m.CreationTimestamp); err != nil { 202 return err 203 } 204 205 if err := validate.FormatOf("creation_timestamp", "body", "date-time", m.CreationTimestamp.String(), formats); err != nil { 206 return err 207 } 208 209 return nil 210 } 211 212 func (m *Platform) validateDisplayName(formats strfmt.Registry) error { 213 214 if err := validate.Required("display_name", "body", m.DisplayName); err != nil { 215 return err 216 } 217 218 return nil 219 } 220 221 func (m *Platform) validateEndOfSupportDate(formats strfmt.Registry) error { 222 if swag.IsZero(m.EndOfSupportDate) { // not required 223 return nil 224 } 225 226 if err := validate.FormatOf("end_of_support_date", "body", "date", m.EndOfSupportDate.String(), formats); err != nil { 227 return err 228 } 229 230 return nil 231 } 232 233 func (m *Platform) validateGpuArchitecture(formats strfmt.Registry) error { 234 if swag.IsZero(m.GpuArchitecture) { // not required 235 return nil 236 } 237 238 if m.GpuArchitecture != nil { 239 if err := m.GpuArchitecture.Validate(formats); err != nil { 240 if ve, ok := err.(*errors.Validation); ok { 241 return ve.ValidateName("gpu_architecture") 242 } 243 return err 244 } 245 } 246 247 return nil 248 } 249 250 func (m *Platform) validateImages(formats strfmt.Registry) error { 251 252 if err := validate.Required("images", "body", m.Images); err != nil { 253 return err 254 } 255 256 for i := 0; i < len(m.Images); i++ { 257 if swag.IsZero(m.Images[i]) { // not required 258 continue 259 } 260 261 if m.Images[i] != nil { 262 if err := m.Images[i].Validate(formats); err != nil { 263 if ve, ok := err.(*errors.Validation); ok { 264 return ve.ValidateName("images" + "." + strconv.Itoa(i)) 265 } 266 return err 267 } 268 } 269 270 } 271 272 return nil 273 } 274 275 func (m *Platform) validateKernel(formats strfmt.Registry) error { 276 277 if err := validate.Required("kernel", "body", m.Kernel); err != nil { 278 return err 279 } 280 281 if m.Kernel != nil { 282 if err := m.Kernel.Validate(formats); err != nil { 283 if ve, ok := err.(*errors.Validation); ok { 284 return ve.ValidateName("kernel") 285 } 286 return err 287 } 288 } 289 290 return nil 291 } 292 293 func (m *Platform) validateKernelVersion(formats strfmt.Registry) error { 294 295 if err := validate.Required("kernel_version", "body", m.KernelVersion); err != nil { 296 return err 297 } 298 299 if m.KernelVersion != nil { 300 if err := m.KernelVersion.Validate(formats); err != nil { 301 if ve, ok := err.(*errors.Validation); ok { 302 return ve.ValidateName("kernel_version") 303 } 304 return err 305 } 306 } 307 308 return nil 309 } 310 311 func (m *Platform) validateLibc(formats strfmt.Registry) error { 312 if swag.IsZero(m.Libc) { // not required 313 return nil 314 } 315 316 if m.Libc != nil { 317 if err := m.Libc.Validate(formats); err != nil { 318 if ve, ok := err.(*errors.Validation); ok { 319 return ve.ValidateName("libc") 320 } 321 return err 322 } 323 } 324 325 return nil 326 } 327 328 func (m *Platform) validateLibcVersion(formats strfmt.Registry) error { 329 if swag.IsZero(m.LibcVersion) { // not required 330 return nil 331 } 332 333 if m.LibcVersion != nil { 334 if err := m.LibcVersion.Validate(formats); err != nil { 335 if ve, ok := err.(*errors.Validation); ok { 336 return ve.ValidateName("libc_version") 337 } 338 return err 339 } 340 } 341 342 return nil 343 } 344 345 func (m *Platform) validateLinks(formats strfmt.Registry) error { 346 347 if err := validate.Required("links", "body", m.Links); err != nil { 348 return err 349 } 350 351 if m.Links != nil { 352 if err := m.Links.Validate(formats); err != nil { 353 if ve, ok := err.(*errors.Validation); ok { 354 return ve.ValidateName("links") 355 } 356 return err 357 } 358 } 359 360 return nil 361 } 362 363 func (m *Platform) validateOperatingSystem(formats strfmt.Registry) error { 364 365 if err := validate.Required("operating_system", "body", m.OperatingSystem); err != nil { 366 return err 367 } 368 369 if m.OperatingSystem != nil { 370 if err := m.OperatingSystem.Validate(formats); err != nil { 371 if ve, ok := err.(*errors.Validation); ok { 372 return ve.ValidateName("operating_system") 373 } 374 return err 375 } 376 } 377 378 return nil 379 } 380 381 func (m *Platform) validateOperatingSystemVersion(formats strfmt.Registry) error { 382 383 if err := validate.Required("operating_system_version", "body", m.OperatingSystemVersion); err != nil { 384 return err 385 } 386 387 if m.OperatingSystemVersion != nil { 388 if err := m.OperatingSystemVersion.Validate(formats); err != nil { 389 if ve, ok := err.(*errors.Validation); ok { 390 return ve.ValidateName("operating_system_version") 391 } 392 return err 393 } 394 } 395 396 return nil 397 } 398 399 func (m *Platform) validatePlatformID(formats strfmt.Registry) error { 400 401 if err := validate.Required("platform_id", "body", m.PlatformID); err != nil { 402 return err 403 } 404 405 if err := validate.FormatOf("platform_id", "body", "uuid", m.PlatformID.String(), formats); err != nil { 406 return err 407 } 408 409 return nil 410 } 411 412 // ContextValidate validate this platform based on the context it is used 413 func (m *Platform) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 414 var res []error 415 416 if err := m.contextValidateCPUArchitecture(ctx, formats); err != nil { 417 res = append(res, err) 418 } 419 420 if err := m.contextValidateCPUExtensions(ctx, formats); err != nil { 421 res = append(res, err) 422 } 423 424 if err := m.contextValidateGpuArchitecture(ctx, formats); err != nil { 425 res = append(res, err) 426 } 427 428 if err := m.contextValidateImages(ctx, formats); err != nil { 429 res = append(res, err) 430 } 431 432 if err := m.contextValidateKernel(ctx, formats); err != nil { 433 res = append(res, err) 434 } 435 436 if err := m.contextValidateKernelVersion(ctx, formats); err != nil { 437 res = append(res, err) 438 } 439 440 if err := m.contextValidateLibc(ctx, formats); err != nil { 441 res = append(res, err) 442 } 443 444 if err := m.contextValidateLibcVersion(ctx, formats); err != nil { 445 res = append(res, err) 446 } 447 448 if err := m.contextValidateLinks(ctx, formats); err != nil { 449 res = append(res, err) 450 } 451 452 if err := m.contextValidateOperatingSystem(ctx, formats); err != nil { 453 res = append(res, err) 454 } 455 456 if err := m.contextValidateOperatingSystemVersion(ctx, formats); err != nil { 457 res = append(res, err) 458 } 459 460 if len(res) > 0 { 461 return errors.CompositeValidationError(res...) 462 } 463 return nil 464 } 465 466 func (m *Platform) contextValidateCPUArchitecture(ctx context.Context, formats strfmt.Registry) error { 467 468 if m.CPUArchitecture != nil { 469 if err := m.CPUArchitecture.ContextValidate(ctx, formats); err != nil { 470 if ve, ok := err.(*errors.Validation); ok { 471 return ve.ValidateName("cpu_architecture") 472 } 473 return err 474 } 475 } 476 477 return nil 478 } 479 480 func (m *Platform) contextValidateCPUExtensions(ctx context.Context, formats strfmt.Registry) error { 481 482 for i := 0; i < len(m.CPUExtensions); i++ { 483 484 if m.CPUExtensions[i] != nil { 485 if err := m.CPUExtensions[i].ContextValidate(ctx, formats); err != nil { 486 if ve, ok := err.(*errors.Validation); ok { 487 return ve.ValidateName("cpu_extensions" + "." + strconv.Itoa(i)) 488 } 489 return err 490 } 491 } 492 493 } 494 495 return nil 496 } 497 498 func (m *Platform) contextValidateGpuArchitecture(ctx context.Context, formats strfmt.Registry) error { 499 500 if m.GpuArchitecture != nil { 501 if err := m.GpuArchitecture.ContextValidate(ctx, formats); err != nil { 502 if ve, ok := err.(*errors.Validation); ok { 503 return ve.ValidateName("gpu_architecture") 504 } 505 return err 506 } 507 } 508 509 return nil 510 } 511 512 func (m *Platform) contextValidateImages(ctx context.Context, formats strfmt.Registry) error { 513 514 for i := 0; i < len(m.Images); i++ { 515 516 if m.Images[i] != nil { 517 if err := m.Images[i].ContextValidate(ctx, formats); err != nil { 518 if ve, ok := err.(*errors.Validation); ok { 519 return ve.ValidateName("images" + "." + strconv.Itoa(i)) 520 } 521 return err 522 } 523 } 524 525 } 526 527 return nil 528 } 529 530 func (m *Platform) contextValidateKernel(ctx context.Context, formats strfmt.Registry) error { 531 532 if m.Kernel != nil { 533 if err := m.Kernel.ContextValidate(ctx, formats); err != nil { 534 if ve, ok := err.(*errors.Validation); ok { 535 return ve.ValidateName("kernel") 536 } 537 return err 538 } 539 } 540 541 return nil 542 } 543 544 func (m *Platform) contextValidateKernelVersion(ctx context.Context, formats strfmt.Registry) error { 545 546 if m.KernelVersion != nil { 547 if err := m.KernelVersion.ContextValidate(ctx, formats); err != nil { 548 if ve, ok := err.(*errors.Validation); ok { 549 return ve.ValidateName("kernel_version") 550 } 551 return err 552 } 553 } 554 555 return nil 556 } 557 558 func (m *Platform) contextValidateLibc(ctx context.Context, formats strfmt.Registry) error { 559 560 if m.Libc != nil { 561 if err := m.Libc.ContextValidate(ctx, formats); err != nil { 562 if ve, ok := err.(*errors.Validation); ok { 563 return ve.ValidateName("libc") 564 } 565 return err 566 } 567 } 568 569 return nil 570 } 571 572 func (m *Platform) contextValidateLibcVersion(ctx context.Context, formats strfmt.Registry) error { 573 574 if m.LibcVersion != nil { 575 if err := m.LibcVersion.ContextValidate(ctx, formats); err != nil { 576 if ve, ok := err.(*errors.Validation); ok { 577 return ve.ValidateName("libc_version") 578 } 579 return err 580 } 581 } 582 583 return nil 584 } 585 586 func (m *Platform) contextValidateLinks(ctx context.Context, formats strfmt.Registry) error { 587 588 if m.Links != nil { 589 if err := m.Links.ContextValidate(ctx, formats); err != nil { 590 if ve, ok := err.(*errors.Validation); ok { 591 return ve.ValidateName("links") 592 } 593 return err 594 } 595 } 596 597 return nil 598 } 599 600 func (m *Platform) contextValidateOperatingSystem(ctx context.Context, formats strfmt.Registry) error { 601 602 if m.OperatingSystem != nil { 603 if err := m.OperatingSystem.ContextValidate(ctx, formats); err != nil { 604 if ve, ok := err.(*errors.Validation); ok { 605 return ve.ValidateName("operating_system") 606 } 607 return err 608 } 609 } 610 611 return nil 612 } 613 614 func (m *Platform) contextValidateOperatingSystemVersion(ctx context.Context, formats strfmt.Registry) error { 615 616 if m.OperatingSystemVersion != nil { 617 if err := m.OperatingSystemVersion.ContextValidate(ctx, formats); err != nil { 618 if ve, ok := err.(*errors.Validation); ok { 619 return ve.ValidateName("operating_system_version") 620 } 621 return err 622 } 623 } 624 625 return nil 626 } 627 628 // MarshalBinary interface implementation 629 func (m *Platform) MarshalBinary() ([]byte, error) { 630 if m == nil { 631 return nil, nil 632 } 633 return swag.WriteJSON(m) 634 } 635 636 // UnmarshalBinary interface implementation 637 func (m *Platform) UnmarshalBinary(b []byte) error { 638 var res Platform 639 if err := swag.ReadJSON(b, &res); err != nil { 640 return err 641 } 642 *m = res 643 return nil 644 }