76 lines
2.5 KiB
PHP
76 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Providers;
|
|
|
|
use App\Support\Auth\Capabilities;
|
|
use InvalidArgumentException;
|
|
|
|
final class ProviderOperationRegistry
|
|
{
|
|
/**
|
|
* @return array<string, array{provider: string, module: string, label: string, required_capability: string}>
|
|
*/
|
|
public function all(): array
|
|
{
|
|
return [
|
|
'provider.connection.check' => [
|
|
'provider' => 'microsoft',
|
|
'module' => 'health_check',
|
|
'label' => 'Provider connection check',
|
|
'required_capability' => Capabilities::PROVIDER_RUN,
|
|
],
|
|
'inventory_sync' => [
|
|
'provider' => 'microsoft',
|
|
'module' => 'inventory',
|
|
'label' => 'Inventory sync',
|
|
'required_capability' => Capabilities::PROVIDER_RUN,
|
|
],
|
|
'compliance.snapshot' => [
|
|
'provider' => 'microsoft',
|
|
'module' => 'compliance',
|
|
'label' => 'Compliance snapshot',
|
|
'required_capability' => Capabilities::PROVIDER_RUN,
|
|
],
|
|
'restore.execute' => [
|
|
'provider' => 'microsoft',
|
|
'module' => 'restore',
|
|
'label' => 'Restore execution',
|
|
'required_capability' => Capabilities::TENANT_MANAGE,
|
|
],
|
|
'entra_group_sync' => [
|
|
'provider' => 'microsoft',
|
|
'module' => 'directory_groups',
|
|
'label' => 'Directory groups sync',
|
|
'required_capability' => Capabilities::TENANT_SYNC,
|
|
],
|
|
'directory_role_definitions.sync' => [
|
|
'provider' => 'microsoft',
|
|
'module' => 'directory_role_definitions',
|
|
'label' => 'Role definitions sync',
|
|
'required_capability' => Capabilities::TENANT_MANAGE,
|
|
],
|
|
];
|
|
}
|
|
|
|
public function isAllowed(string $operationType): bool
|
|
{
|
|
return array_key_exists($operationType, $this->all());
|
|
}
|
|
|
|
/**
|
|
* @return array{provider: string, module: string, label: string, required_capability: string}
|
|
*/
|
|
public function get(string $operationType): array
|
|
{
|
|
$operationType = trim($operationType);
|
|
|
|
$definition = $this->all()[$operationType] ?? null;
|
|
|
|
if (! is_array($definition)) {
|
|
throw new InvalidArgumentException("Unknown provider operation type: {$operationType}");
|
|
}
|
|
|
|
return $definition;
|
|
}
|
|
}
|