<?php

declare(strict_types=1);

/** GET /api/v1/administration/license-manager/modules */
final class MyronListModuleLicensesAction implements MyronAction
{
    public function __construct(private readonly MyronModuleLicenseManagerService $service) {}

    public function metadata(): MyronActionMetadata
    {
        return new MyronActionMetadata(
            uri: '/api/v1/administration/license-manager/modules',
            method: 'GET',
            domain: 'administration',
            resource: 'license-manager',
            verb: 'list-modules',
            inputSchema: ['type' => 'object', 'properties' => []],
            outputSchema: [
                'type' => 'object',
                'properties' => [
                    'modules' => ['type' => 'array'],
                    'catalogEmpty' => ['type' => 'boolean'],
                    'serviceReachable' => ['type' => 'boolean'],
                    'stage' => ['type' => 'string'],
                ],
            ],
            requiredScope: MyronApiScopes::ADMINISTRATION_READ,
            summary: 'List paid Module license state for the local License Manager scaffold.',
            sideEffects: [],
            audienceClass: 3,
            snapshotInclude: false,
            exposeToMcp: true,
        );
    }

    public function execute(array $input, MyronActionCallerContext $caller): MyronActionResult
    {
        return MyronActionResult::ok($this->service->listModules());
    }
}
