|
|
|
|
@ -3,6 +3,7 @@
|
|
|
|
|
namespace App\Controllers;
|
|
|
|
|
|
|
|
|
|
use App\Services\Cloud\CloudAccess;
|
|
|
|
|
use App\Services\Cloud\CloudAdminVpcControlService;
|
|
|
|
|
use App\Services\Cloud\CloudAdminVpcCidrPoolService;
|
|
|
|
|
use App\Services\Cloud\CloudError;
|
|
|
|
|
use App\Services\Cloud\CloudInput;
|
|
|
|
|
@ -10,7 +11,7 @@ use App\Services\Cloud\CloudInput;
|
|
|
|
|
/** Administrator API for the region-owned VPC address catalog. */
|
|
|
|
|
final class CloudAdminVpcController
|
|
|
|
|
{
|
|
|
|
|
private function actor($request, bool $write): void
|
|
|
|
|
private function actor($request, bool $write): array
|
|
|
|
|
{
|
|
|
|
|
$actor = $request->getAttribute('cloud_actor') ?? CloudAccess::actor(false);
|
|
|
|
|
if (!($actor['is_admin'] ?? false)) {
|
|
|
|
|
@ -19,6 +20,7 @@ final class CloudAdminVpcController
|
|
|
|
|
if ($write) {
|
|
|
|
|
CloudAccess::manage($actor);
|
|
|
|
|
}
|
|
|
|
|
return $actor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function pools($request, $response, $args = [])
|
|
|
|
|
@ -46,4 +48,28 @@ final class CloudAdminVpcController
|
|
|
|
|
return $response->withJson($result, $status)
|
|
|
|
|
->withHeader('Cache-Control', 'private, no-store');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function control($request, $response)
|
|
|
|
|
{
|
|
|
|
|
$actor = $this->actor($request, false);
|
|
|
|
|
return $response->withJson(CloudAdminVpcControlService::page(
|
|
|
|
|
$actor, $request->getQueryParams()
|
|
|
|
|
))->withHeader('Cache-Control', 'private, no-store');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function networks($request, $response)
|
|
|
|
|
{
|
|
|
|
|
$actor = $this->actor($request, false);
|
|
|
|
|
return $response->withJson(CloudAdminVpcControlService::listing(
|
|
|
|
|
$actor, $request->getQueryParams()
|
|
|
|
|
))->withHeader('Cache-Control', 'private, no-store');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function detail($request, $response, $args)
|
|
|
|
|
{
|
|
|
|
|
$actor = $this->actor($request, false);
|
|
|
|
|
return $response->withJson(CloudAdminVpcControlService::detail(
|
|
|
|
|
$actor, (int) ($args['id'] ?? 0)
|
|
|
|
|
))->withHeader('Cache-Control', 'private, no-store');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|