<?php

namespace Containers\Dto;

readonly class ContainersSummaryDto
{
    /**
     * @param string[] $engines
     */
    public function __construct(
        public string  $hostkey,
        public int     $containers_running,
        public int     $containers_total,
        public int     $images_named,
        public int     $images_total,
        public int     $images_total_size_bytes,
        public int     $volumes_count,
        public int     $volumes_total_size_bytes,
        public array   $engines,
        public ?string $last_collected_at = null,
    ) {
    }

    public function toArray(): array
    {
        return [
            'hostkey' => $this->hostkey,
            'last_collected_at' => $this->last_collected_at,
            'containers' => [
                'running' => $this->containers_running,
                'total' => $this->containers_total,
            ],
            'images' => [
                'named' => $this->images_named,
                'total' => $this->images_total,
                'total_size_bytes' => $this->images_total_size_bytes,
            ],
            'volumes' => [
                'count' => $this->volumes_count,
                'total_size_bytes' => $this->volumes_total_size_bytes,
            ],
            'engines' => $this->engines,
        ];
    }
}
