new changes
This commit is contained in:
55
panel-api/app/Modules/Agents/AgentController.php
Normal file
55
panel-api/app/Modules/Agents/AgentController.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Agents;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
class AgentController extends Controller
|
||||
{
|
||||
public function __construct(private readonly AgentSessionRepository $sessionsRepo)
|
||||
{
|
||||
}
|
||||
|
||||
public function issueEnrollmentToken(string $server): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'data' => [
|
||||
'server_id' => $server,
|
||||
'token_type' => 'bootstrap',
|
||||
'expires_in_sec' => 900,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function capabilities(string $server): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'data' => [
|
||||
'server_id' => $server,
|
||||
'capabilities' => [],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function sessions(string $server): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'data' => [
|
||||
'server_id' => $server,
|
||||
'sessions' => $this->sessionsRepo->listByServer($server),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function heartbeat(Request $request, string $server): JsonResponse
|
||||
{
|
||||
$agentUid = (string) $request->input('agent_uid', '');
|
||||
$session = $this->sessionsRepo->touchHeartbeat($server, $agentUid, $request->all());
|
||||
|
||||
return response()->json([
|
||||
'data' => $session,
|
||||
]);
|
||||
}
|
||||
}
|
||||
22
panel-api/app/Modules/Agents/AgentSessionRepository.php
Normal file
22
panel-api/app/Modules/Agents/AgentSessionRepository.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Agents;
|
||||
|
||||
class AgentSessionRepository
|
||||
{
|
||||
public function listByServer(string $serverId): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function touchHeartbeat(string $serverId, string $agentUid, array $payload): array
|
||||
{
|
||||
return [
|
||||
'server_id' => $serverId,
|
||||
'agent_uid' => $agentUid,
|
||||
'status' => 'online',
|
||||
'last_seen_at' => now()->toISOString(),
|
||||
'payload' => $payload,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user