|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Controllers;
|
|
|
|
|
|
|
|
|
|
use App\Services\Cloud\CloudAccess;
|
|
|
|
|
use App\Services\Cloud\CloudAdminOperationRecoveryService;
|
|
|
|
|
use App\Services\Cloud\CloudAdminOperationsService;
|
|
|
|
|
use App\Services\Cloud\CloudInput;
|
|
|
|
|
use App\Services\Cloud\CloudPaymentEffectResolutionService;
|
|
|
|
|
|
|
|
|
|
/** Operations inventory, read-only inspection and separately authorized work. */
|
|
|
|
|
final class CloudAdminOperationsController
|
|
|
|
|
{
|
|
|
|
|
public function index($request, $response)
|
|
|
|
|
{
|
|
|
|
|
return $response->withJson(CloudAdminOperationsService::page(
|
|
|
|
|
$request->getAttribute('cloud_actor') ?? CloudAccess::actor(false),
|
|
|
|
|
$request->getQueryParams()
|
|
|
|
|
))->withHeader('Cache-Control', 'private, no-store');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function detail($request, $response, $args)
|
|
|
|
|
{
|
|
|
|
|
return $response->withJson(CloudAdminOperationsService::detail(
|
|
|
|
|
$request->getAttribute('cloud_actor') ?? CloudAccess::actor(false),
|
|
|
|
|
(string) ($args['id'] ?? '')
|
|
|
|
|
))->withHeader('Cache-Control', 'private, no-store');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function inspect($request, $response, $args)
|
|
|
|
|
{
|
|
|
|
|
$actor = $request->getAttribute('cloud_actor')
|
|
|
|
|
?? CloudAccess::actor(false);
|
|
|
|
|
CloudInput::only(CloudInput::object($request), []);
|
|
|
|
|
$id = (string) ($args['id'] ?? '');
|
|
|
|
|
$inspection = CloudAdminOperationRecoveryService::inspect(
|
|
|
|
|
$actor, $id
|
|
|
|
|
);
|
|
|
|
|
return $response->withJson(
|
|
|
|
|
CloudAdminOperationsService::detail($actor, $id)
|
|
|
|
|
+ ['inspection' => $inspection]
|
|
|
|
|
)->withHeader('Cache-Control', 'private, no-store');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function resolveEffect($request, $response, $args)
|
|
|
|
|
{
|
|
|
|
|
$actor = $request->getAttribute('cloud_actor')
|
|
|
|
|
?? CloudAccess::actor(false);
|
|
|
|
|
$id = (string) ($args['id'] ?? '');
|
|
|
|
|
$body = CloudInput::object($request);
|
|
|
|
|
CloudInput::only($body, ['resolution', 'reason']);
|
|
|
|
|
if (CloudPaymentEffectResolutionService::handles($id)) {
|
|
|
|
|
$inspection = CloudPaymentEffectResolutionService::resolve(
|
|
|
|
|
$actor,
|
|
|
|
|
$id,
|
|
|
|
|
$body
|
|
|
|
|
);
|
|
|
|
|
return $response->withJson(
|
|
|
|
|
CloudAdminOperationsService::detail($actor, $id)
|
|
|
|
|
+ ['inspection' => $inspection]
|
|
|
|
|
)->withHeader('Cache-Control', 'private, no-store');
|
|
|
|
|
}
|
|
|
|
|
$inspection = CloudAdminOperationRecoveryService::inspect($actor, $id);
|
|
|
|
|
$fenceResolution = CloudAdminOperationRecoveryService::resolveFence(
|
|
|
|
|
$actor,
|
|
|
|
|
$id,
|
|
|
|
|
is_string($body['resolution'] ?? null)
|
|
|
|
|
? $body['resolution'] : '',
|
|
|
|
|
is_string($body['reason'] ?? null) ? trim($body['reason']) : '',
|
|
|
|
|
$inspection
|
|
|
|
|
);
|
|
|
|
|
return $response->withJson(
|
|
|
|
|
CloudAdminOperationsService::resolveEffect(
|
|
|
|
|
$actor, $id, $body, $inspection, $fenceResolution
|
|
|
|
|
) + ['fence_resolution' => $fenceResolution]
|
|
|
|
|
)->withHeader('Cache-Control', 'private, no-store');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function forceDelete($request, $response, $args)
|
|
|
|
|
{
|
|
|
|
|
return $response->withJson(
|
|
|
|
|
CloudAdminOperationRecoveryService::forceDelete(
|
|
|
|
|
$request->getAttribute('cloud_actor')
|
|
|
|
|
?? CloudAccess::actor(false),
|
|
|
|
|
(string) ($args['id'] ?? ''),
|
|
|
|
|
CloudInput::object($request)
|
|
|
|
|
),
|
|
|
|
|
202
|
|
|
|
|
)->withHeader('Cache-Control', 'private, no-store');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function repairVpc($request, $response, $args)
|
|
|
|
|
{
|
|
|
|
|
return $response->withJson(
|
|
|
|
|
CloudAdminOperationRecoveryService::repairVpc(
|
|
|
|
|
$request->getAttribute('cloud_actor')
|
|
|
|
|
?? CloudAccess::actor(false),
|
|
|
|
|
(string) ($args['id'] ?? ''),
|
|
|
|
|
CloudInput::object($request)
|
|
|
|
|
),
|
|
|
|
|
202
|
|
|
|
|
)->withHeader('Cache-Control', 'private, no-store');
|
|
|
|
|
}
|
|
|
|
|
}
|