# Nested Provisioning Contracts
#
# Type definitions for nested VM and container provisioning.

{
  VolumeType = [| 'local, 'nfs, 'cifs, 'cloud, 'host |],
  CloudProvider = [| 'aws, 'azure, 'gcp, 'minio |],
  NetworkType = [| 'bridge, 'overlay, 'host, 'vlan |],
  RestartPolicy = [| 'no, 'always, 'on_failure, 'unless_stopped |],
  ContainerRuntime = [| 'docker, 'podman, 'containerd |],
  DeploymentStrategy = [| 'rolling, 'blue_green, 'canary |],
  TrafficDirection = [| 'inbound, 'outbound, 'both |],
  NetworkProtocol = [| 'tcp, 'udp, 'icmp, 'all |],
  PolicyAction = [| 'allow, 'deny, 'log |],

  VolumeConfig = {
    name | String,
    description | optional | String,
    type | VolumeType,
    size_gb | optional | Number,
    mount_path | String,
    readonly | optional | Bool,
    mount_mode | optional | String,
    host | optional | String,
    path | optional | String,
    username | optional | String,
    password | optional | String,
    bucket | optional | String,
    provider | optional | CloudProvider,
    region | optional | String,
    iops | optional | Number,
    throughput_mbps | optional | Number,
  },

  NetworkConfig = {
    name | String,
    description | optional | String,
    type | NetworkType,
    vlan_id | optional | Number,
    subnet | String,
    gateway | optional | String,
    dns_servers | optional,
    mtu | optional | Number,
    dhcp_enabled | optional | Bool,
    dhcp_start | optional | String,
    dhcp_end | optional | String,
    allow_outbound | optional | Bool,
    allow_inbound | optional | Bool,
    rules | optional,
    bandwidth_limit_mbps | optional | Number,
    latency_ms | optional | Number,
  },

  NestedVmConfig = {
    name | String,
    description | optional | String,
    parent_vm | String,
    cpu | Number,
    memory_mb | Number,
    disk_gb | Number,
    nested_virt | optional | Bool,
    base_image | optional | String,
    from_golden_image | optional | String,
    networks,
    static_ip | optional | String,
    dns | optional,
    volumes | optional,
    extra_disks | optional,
    auto_start | optional | Bool,
    start_order | optional | Number,
    restart_policy | optional | RestartPolicy,
  },

  ContainerConfig = {
    name | String,
    image | String,
    tag | optional | String,
    parent_vm | String,
    runtime | ContainerRuntime,
    cpu_millicores | optional | Number,
    memory_mb | optional | Number,
    disk_gb | optional | Number,
    networks | optional,
    expose_ports | optional,
    environment | optional,
    volumes | optional,
    tmpfs | optional | Number,
    auto_start | optional | Bool,
    restart_policy | optional | RestartPolicy,
    health_check | optional,
  },

  MultiTierDeployment = {
    name | String,
    version | optional | String,
    description | optional | String,
    networks,
    volumes,
    parent_vms,
    nested_vms,
    containers,
    replicas | optional | Number,
    strategy | optional | DeploymentStrategy,
    health_check_interval | optional | Number,
  },

  NetworkPolicy = {
    name | String,
    description | optional | String,
    direction | TrafficDirection,
    protocol | NetworkProtocol,
    source | optional | String,
    destination | optional | String,
    port_range | optional | String,
    action | PolicyAction,
    priority | optional | Number,
  },

  VolumeSnapshot = {
    name | String,
    volume_name | String,
    created_at | String,
    size_gb | Number,
    checksum | String,
    description | optional | String,
    retention_days | optional | Number,
    auto_delete | optional | Bool,
  },

  NestedProvisioningPolicy = {
    max_nesting_depth | Number,
    max_vms_per_parent | Number,
    max_containers_per_vm | Number,
    max_cpu_per_vm | Number,
    max_memory_per_vm | Number,
    max_disk_per_vm | Number,
    default_network_type | String,
    enable_ipv6 | optional | Bool,
    enable_vlan_tagging | optional | Bool,
    default_volume_type | String,
    snapshot_retention_days | Number,
    enable_security_hardening | optional | Bool,
    enable_network_isolation | optional | Bool,
    require_auth_between_tiers | optional | Bool,
  },
}
