new changes

This commit is contained in:
Niranjan
2026-04-07 20:29:49 +05:30
parent 8fe63c7cf4
commit 31fe556bb0
79 changed files with 2917 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
<?php
namespace App\Modules\Ops;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
class BackupController extends Controller
{
public function __construct(private readonly OpsWorkflowService $workflow)
{
}
public function run(Request $request): JsonResponse
{
$tenantId = (string) $request->attributes->get('tenant_id', '');
return response()->json(['data' => $this->workflow->backupRun($tenantId, $request->all())], 202);
}
public function restore(Request $request): JsonResponse
{
$tenantId = (string) $request->attributes->get('tenant_id', '');
return response()->json(['data' => $this->workflow->backupRestore($tenantId, $request->all())], 202);
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Modules\Ops;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
class CronController extends Controller
{
public function __construct(private readonly OpsWorkflowService $workflow)
{
}
public function index(Request $request): JsonResponse
{
$tenantId = (string) $request->attributes->get('tenant_id', '');
return response()->json(['data' => $this->workflow->cronList($tenantId, $request->all())], 202);
}
public function store(Request $request): JsonResponse
{
$tenantId = (string) $request->attributes->get('tenant_id', '');
return response()->json(['data' => $this->workflow->cronCreate($tenantId, $request->all())], 202);
}
public function destroy(Request $request): JsonResponse
{
$tenantId = (string) $request->attributes->get('tenant_id', '');
return response()->json(['data' => $this->workflow->cronDelete($tenantId, $request->all())], 202);
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Modules\Ops;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
class FileOpsController extends Controller
{
public function __construct(private readonly OpsWorkflowService $workflow)
{
}
public function list(Request $request): JsonResponse
{
$tenantId = (string) $request->attributes->get('tenant_id', '');
return response()->json(['data' => $this->workflow->fileList($tenantId, $request->all())], 202);
}
public function read(Request $request): JsonResponse
{
$tenantId = (string) $request->attributes->get('tenant_id', '');
return response()->json(['data' => $this->workflow->fileRead($tenantId, $request->all())], 202);
}
public function write(Request $request): JsonResponse
{
$tenantId = (string) $request->attributes->get('tenant_id', '');
return response()->json(['data' => $this->workflow->fileWrite($tenantId, $request->all())], 202);
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Modules\Ops;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
class FirewallController extends Controller
{
public function __construct(private readonly OpsWorkflowService $workflow)
{
}
public function index(Request $request): JsonResponse
{
$tenantId = (string) $request->attributes->get('tenant_id', '');
return response()->json(['data' => $this->workflow->firewallList($tenantId, $request->all())], 202);
}
public function store(Request $request): JsonResponse
{
$tenantId = (string) $request->attributes->get('tenant_id', '');
return response()->json(['data' => $this->workflow->firewallAdd($tenantId, $request->all())], 202);
}
public function destroy(Request $request): JsonResponse
{
$tenantId = (string) $request->attributes->get('tenant_id', '');
return response()->json(['data' => $this->workflow->firewallDelete($tenantId, $request->all())], 202);
}
}

View File

@@ -0,0 +1,71 @@
<?php
namespace App\Modules\Ops;
class OpsCommandFactory
{
public function fileList(string $tenantId, array $input): array
{
return $this->cmd($tenantId, 'FILE_LIST', 'file_list_', $input);
}
public function fileRead(string $tenantId, array $input): array
{
return $this->cmd($tenantId, 'FILE_READ', 'file_read_', $input);
}
public function fileWrite(string $tenantId, array $input): array
{
return $this->cmd($tenantId, 'FILE_WRITE', 'file_write_', $input);
}
public function cronList(string $tenantId, array $input): array
{
return $this->cmd($tenantId, 'CRON_LIST', 'cron_list_', $input);
}
public function cronCreate(string $tenantId, array $input): array
{
return $this->cmd($tenantId, 'CRON_CREATE', 'cron_create_', $input);
}
public function cronDelete(string $tenantId, array $input): array
{
return $this->cmd($tenantId, 'CRON_DELETE', 'cron_delete_', $input);
}
public function firewallList(string $tenantId, array $input): array
{
return $this->cmd($tenantId, 'FIREWALL_RULE_LIST', 'fw_list_', $input);
}
public function firewallAdd(string $tenantId, array $input): array
{
return $this->cmd($tenantId, 'FIREWALL_RULE_ADD', 'fw_add_', $input);
}
public function firewallDelete(string $tenantId, array $input): array
{
return $this->cmd($tenantId, 'FIREWALL_RULE_DELETE', 'fw_delete_', $input);
}
public function backupRun(string $tenantId, array $input): array
{
return $this->cmd($tenantId, 'BACKUP_RUN', 'backup_run_', $input);
}
public function backupRestore(string $tenantId, array $input): array
{
return $this->cmd($tenantId, 'BACKUP_RESTORE', 'backup_restore_', $input);
}
private function cmd(string $tenantId, string $type, string $prefix, array $input): array
{
return [
'tenant_id' => $tenantId,
'type' => $type,
'idempotency_key' => $input['idempotency_key'] ?? uniqid($prefix, true),
'args' => $input,
];
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace App\Modules\Ops;
use App\Modules\Jobs\CommandOrchestrator;
class OpsWorkflowService
{
public function __construct(
private readonly CommandOrchestrator $orchestrator,
private readonly OpsCommandFactory $commands
) {
}
public function fileList(string $tenantId, array $input): array { return $this->orchestrator->dispatch($this->commands->fileList($tenantId, $input)); }
public function fileRead(string $tenantId, array $input): array { return $this->orchestrator->dispatch($this->commands->fileRead($tenantId, $input)); }
public function fileWrite(string $tenantId, array $input): array { return $this->orchestrator->dispatch($this->commands->fileWrite($tenantId, $input)); }
public function cronList(string $tenantId, array $input): array { return $this->orchestrator->dispatch($this->commands->cronList($tenantId, $input)); }
public function cronCreate(string $tenantId, array $input): array { return $this->orchestrator->dispatch($this->commands->cronCreate($tenantId, $input)); }
public function cronDelete(string $tenantId, array $input): array { return $this->orchestrator->dispatch($this->commands->cronDelete($tenantId, $input)); }
public function firewallList(string $tenantId, array $input): array { return $this->orchestrator->dispatch($this->commands->firewallList($tenantId, $input)); }
public function firewallAdd(string $tenantId, array $input): array { return $this->orchestrator->dispatch($this->commands->firewallAdd($tenantId, $input)); }
public function firewallDelete(string $tenantId, array $input): array { return $this->orchestrator->dispatch($this->commands->firewallDelete($tenantId, $input)); }
public function backupRun(string $tenantId, array $input): array { return $this->orchestrator->dispatch($this->commands->backupRun($tenantId, $input)); }
public function backupRestore(string $tenantId, array $input): array { return $this->orchestrator->dispatch($this->commands->backupRestore($tenantId, $input)); }
}