<?php

declare(strict_types=1);

/** APO-249 — GET /api/v1/administration/roles */
final class MyronListRolesAction implements MyronAction
{
    public function metadata(): MyronActionMetadata
    {
        return new MyronActionMetadata(
            uri: '/api/v1/administration/roles',
            method: 'GET',
            domain: 'administration',
            resource: 'role',
            verb: 'list',
            inputSchema: ['type' => 'object', 'properties' => []],
            outputSchema: ['type' => 'object', 'properties' => ['roles' => ['type' => 'object']]],
            requiredScope: MyronApiScopes::ADMINISTRATION_READ,
            summary: 'List code-defined role templates and granted scope sets.',
            audienceClass: 3,
            snapshotInclude: false,
            exposeToMcp: true
        );
    }

    public function execute(array $input, MyronActionCallerContext $caller): MyronActionResult
    {
        return MyronActionResult::ok(['roles' => MyronAuthRepository::roleCatalog()]);
    }
}
