<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Api\V1\Admin\Agent\AgentNodeTreeController;
use App\Http\Controllers\Api\V1\Admin\Agent\AgentNodeIndexController;
use App\Http\Controllers\Api\V1\Admin\Agent\AgentNodeShowController;
use App\Http\Controllers\Api\V1\Admin\Agent\AgentNodeStoreController;
use App\Http\Controllers\Api\V1\Admin\Agent\AgentNodeUpdateController;
use App\Http\Controllers\Api\V1\Admin\Agent\AgentNodeDestroyController;
use App\Http\Controllers\Api\V1\Admin\Agent\AgentNodeChildrenController;
use App\Http\Controllers\Api\V1\Admin\Agent\AgentNodeRoleIndexController;
use App\Http\Controllers\Api\V1\Admin\Agent\AgentNodeRoleStoreController;
use App\Http\Controllers\Api\V1\Admin\Agent\AgentRoleUpdateController;
use App\Http\Controllers\Api\V1\Admin\Agent\AgentRolePermissionSyncController;
use App\Http\Controllers\Api\V1\Admin\Agent\AgentRoleDestroyController;
use App\Http\Controllers\Api\V1\Admin\Agent\AgentNodeAdminUserIndexController;
use App\Http\Controllers\Api\V1\Admin\Agent\AgentNodeAdminUserStoreController;
use App\Http\Controllers\Api\V1\Admin\Agent\AgentAdminUserRoleSyncController;
use App\Http\Controllers\Api\V1\Admin\Agent\AgentAdminUserDestroyController;
use App\Http\Controllers\Api\V1\Admin\Agent\AgentNodeDelegationGrantIndexController;
use App\Http\Controllers\Api\V1\Admin\Agent\AgentNodeDelegationGrantSyncController;
use App\Http\Controllers\Api\V1\Admin\Agent\AgentLineStoreController;
use App\Http\Controllers\Api\V1\Admin\Agent\AgentLineShowController;
use App\Http\Controllers\Api\V1\Admin\Agent\AgentNodeProfileController;

Route::middleware('admin.api-resource')
    ->group(function (): void {
        Route::post('agent-lines', AgentLineStoreController::class)
            ->name('api.v1.admin.agent-lines.store');
        Route::get('agent-lines/{admin_site}', AgentLineShowController::class)
            ->name('api.v1.admin.agent-lines.show');
        Route::get('agent-nodes/tree', AgentNodeTreeController::class)
            ->name('api.v1.admin.agent-nodes.tree');
        Route::get('agent-nodes', AgentNodeIndexController::class)
            ->name('api.v1.admin.agent-nodes.index');
        Route::post('agent-nodes', AgentNodeStoreController::class)
            ->name('api.v1.admin.agent-nodes.store');
        Route::get('agent-nodes/{agent_node}/roles', AgentNodeRoleIndexController::class)
            ->name('api.v1.admin.agent-roles.index');
        Route::post('agent-nodes/{agent_node}/roles', AgentNodeRoleStoreController::class)
            ->name('api.v1.admin.agent-roles.store');
        Route::get('agent-nodes/{agent_node}/admin-users', AgentNodeAdminUserIndexController::class)
            ->name('api.v1.admin.agent-admin-users.index');
        Route::post('agent-nodes/{agent_node}/admin-users', AgentNodeAdminUserStoreController::class)
            ->name('api.v1.admin.agent-admin-users.store');
        Route::get('agent-nodes/{agent_node}/delegation-grants', AgentNodeDelegationGrantIndexController::class)
            ->name('api.v1.admin.agent-delegation-grants.index');
        Route::put('agent-nodes/{agent_node}/delegation-grants', AgentNodeDelegationGrantSyncController::class)
            ->name('api.v1.admin.agent-delegation-grants.sync');
        Route::get('agent-nodes/{agent_node}/profile', [AgentNodeProfileController::class, 'show'])
            ->name('api.v1.admin.agent-nodes.profile.show');
        Route::put('agent-nodes/{agent_node}/profile', [AgentNodeProfileController::class, 'update'])
            ->name('api.v1.admin.agent-nodes.profile.update');
        Route::get('agent-nodes/{agent_node}', AgentNodeShowController::class)
            ->name('api.v1.admin.agent-nodes.show');
        Route::put('agent-nodes/{agent_node}', AgentNodeUpdateController::class)
            ->name('api.v1.admin.agent-nodes.update');
        Route::delete('agent-nodes/{agent_node}', AgentNodeDestroyController::class)
            ->name('api.v1.admin.agent-nodes.destroy');
        Route::get('agent-nodes/{agent_node}/children', AgentNodeChildrenController::class)
            ->name('api.v1.admin.agent-nodes.children');

        Route::put('agent-roles/{admin_role}', AgentRoleUpdateController::class)
            ->name('api.v1.admin.agent-roles.update');
        Route::put('agent-roles/{admin_role}/permissions', AgentRolePermissionSyncController::class)
            ->name('api.v1.admin.agent-roles.permissions.sync');
        Route::delete('agent-roles/{admin_role}', AgentRoleDestroyController::class)
            ->name('api.v1.admin.agent-roles.destroy');

        Route::put('agent-admin-users/{admin_user}/roles', AgentAdminUserRoleSyncController::class)
            ->name('api.v1.admin.agent-admin-users.roles.sync');
        Route::delete('agent-admin-users/{admin_user}', AgentAdminUserDestroyController::class)
            ->name('api.v1.admin.agent-admin-users.destroy');
    });
