# Golden Image Contracts
#
# Type definitions for golden image building and caching.

{
  BaseOs = [| 'ubuntu, 'debian, 'centos, 'fedora, 'rhel |],
  Arch = [| 'x86_64, 'aarch64, 'arm64 |],
  DiskFormat = [| 'qcow2, 'raw, 'vmdk |],
  BuildStatus = [| 'queued, 'building, 'testing, 'caching, 'completed, 'failed |],
  StorageFormat = [| 'qcow2, 'raw, 'compressed |],
  VersionNaming = [| 'semantic, 'timestamp, 'sequential |],

  GoldenImageConfig = {
    name | String,
    description | optional | String,
    base_os | BaseOs,
    os_version | String,
    arch | Arch,
    taskservs | optional,
    taskserv_versions | optional,
    exclude_taskservs | optional,
    optimize | optional | Bool,
    include_dev_tools | optional | Bool,
    include_kernel_headers | optional | Bool,
    cleanup_package_manager | optional | Bool,
    disk_size_gb | optional | Number,
    disk_format | optional | DiskFormat,
    compression | optional | Bool,
    cache_enabled | optional | Bool,
    cache_ttl_days | optional | Number,
    cache_storage | optional | String,
    network_config | optional | String,
    dns_servers | optional,
    security_hardening | optional | Bool,
    auto_updates | optional | Bool,
    ssh_public_keys | optional,
    build_timeout_minutes | optional | Number,
    build_retries | optional | Number,
    parallel_builds | optional | Bool,
  },

  GoldenImageBuildJob = {
    job_id | String,
    image_name | String,
    image_version | String,
    image_config,
    status | BuildStatus,
    started_at | optional | String,
    completed_at | optional | String,
    duration_seconds | optional | Number,
    progress_percent | optional | Number,
    current_step | optional | String,
    current_step_progress | optional | Number,
    output_path | optional | String,
    image_size_gb | optional | Number,
    checksum | optional | String,
    error_message | optional | String,
    retry_count | optional | Number,
    last_error | optional | String,
    build_log_path | optional | String,
    test_log_path | optional | String,
  },

  GoldenImageVersion = {
    image_name | String,
    version | String,
    build_number | optional | Number,
    created_at | String,
    created_by | optional | String,
    description | optional | String,
    image_path | String,
    image_size_gb | Number,
    checksum | String,
    base_image_version | optional | String,
    taskserv_versions | optional,
    build_job_id | optional | String,
    usage_count | optional | Number,
    vm_instances | optional,
    last_used_at | optional | String,
    deprecated | optional | Bool,
    replacement_version | optional | String,
  },

  GoldenImageCache = {
    cache_id | String,
    image_name | String,
    image_version | String,
    storage_path | String,
    storage_format | StorageFormat,
    disk_size_gb | Number,
    cached_at | String,
    accessed_at | optional | String,
    expires_at | optional | String,
    ttl_days | optional | Number,
    is_valid | Bool,
    checksum | String,
    last_verification | optional | String,
    access_count | optional | Number,
    hit_count | optional | Number,
    last_vm_created | optional | String,
  },

  ImageBuildSteps = {
    prepare_base | optional | Bool,
    update_packages | optional | Bool,
    install_dependencies | optional | Bool,
    install_taskservs | optional | Bool,
    install_order | optional,
    parallel_install | optional | Bool,
    apply_config | optional | Bool,
    apply_security_hardening | optional | Bool,
    apply_optimizations | optional | Bool,
    run_tests | optional | Bool,
    test_scripts | optional,
    cleanup_caches | optional | Bool,
    cleanup_temp_files | optional | Bool,
    remove_build_artifacts | optional | Bool,
    compress_image | optional | Bool,
    generate_checksums | optional | Bool,
    verify_image | optional | Bool,
  },

  ImageBuildPolicy = {
    default_os | String,
    default_version | String,
    default_arch | String,
    default_disk_size_gb | Number,
    max_parallel_builds | Number,
    max_build_time_minutes | Number,
    max_image_size_gb | Number,
    cache_enabled | Bool,
    cache_location | String,
    default_cache_ttl_days | Number,
    max_cache_size_gb | Number,
    auto_cleanup_expired | Bool,
    cleanup_interval_hours | Number,
    min_disk_free_percent | Number,
    auto_create_versions | Bool,
    version_naming | String,
    default_optimize | Bool,
    default_compression | Bool,
    default_security_hardening | Bool,
  },

  GoldenImageRegistry = {
    registry_id | String,
    location | String,
    created_at | String,
    images,
    versions,
    builds,
    cache,
    policy,
    policy_version | optional | String,
    total_images | optional | Number,
    total_versions | optional | Number,
    total_cached_gb | optional | Number,
    total_builds | optional | Number,
  },
}
