<?php

namespace App\Dto\Output;

use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\Get;
use App\Entity\ImageRepository;
use Symfony\Component\Serializer\Annotation\Groups;

#[Get(shortName: 'ImageRepository')]
class ImageRepositoryOutput extends AbstractOutput
{
    #[Groups(['repository:read', 'image:read', 'client:read', "organizational-unit:read", "image-image-repository:read"])]
    #[ApiProperty(
        description: 'El nombre del repositorio de imágenes',
        example: 'Repositorio Principal'
    )]
    public ?string $name = '';

    #[Groups(['repository:read'])]
    #[ApiProperty(
        description: 'La dirección IP del servidor del repositorio',
        example: '192.168.1.50'
    )]
    public ?string $ip = '';

    #[Groups(['repository:read'])]
    #[ApiProperty(
        description: 'Comentarios sobre el repositorio',
        example: 'Servidor principal de almacenamiento de imágenes'
    )]
    public ?string $comments = '';

    #[Groups(['repository:read'])]
    #[ApiProperty(
        description: 'El puerto SSH del servidor',
        example: '22'
    )]
    public ?string $sshPort = '';

    #[Groups(['repository:read'])]
    #[ApiProperty(
        description: 'El usuario SSH para acceder al repositorio',
        example: 'opengnsys'
    )]
    public ?string $user = '';

    #[Groups(['repository:read'])]
    #[ApiProperty(
        description: 'Fecha de creación del repositorio',
        example: '2024-01-15T10:30:00+00:00'
    )]
    public \DateTime $createdAt;

    #[Groups(['repository:read'])]
    #[ApiProperty(
        description: 'Usuario que creó este registro',
        example: 'admin'
    )]
    public ?string $createdBy = null;

    public function __construct(ImageRepository $imageRepository, bool $status = true)
    {
        parent::__construct($imageRepository);

        $this->name = $imageRepository->getName();
        $this->ip = $imageRepository->getIp();
        $this->comments = $imageRepository->getComments();
        $this->sshPort = $imageRepository->getSshPort();
        $this->user = $imageRepository->getUser();
        $this->createdAt = $imageRepository->getCreatedAt();
        $this->createdBy = $imageRepository->getCreatedBy();
    }

}