<?php

declare(strict_types=1);

namespace App\Controller\OgDhcp;

use App\Service\OgDhcp\StatusService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\AsController;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;

#[Route('/og-dhcp')]
#[AsController]
class OgDhcpController extends AbstractController
{
    public function __construct(
        private readonly StatusService $ogdhcpStatusService,
    )
    {
    }

    /**
     * @throws TransportExceptionInterface
     * @throws ServerExceptionInterface
     * @throws RedirectionExceptionInterface
     * @throws ClientExceptionInterface
     */
    #[Route('/status', name: 'ogdhcp_status',  methods: ['GET'])]
    public function status(): JsonResponse
    {
        $data = $this->ogdhcpStatusService->__invoke();

        return new JsonResponse( data: $data, status: Response::HTTP_OK);
    }
}
