Skip to content
Snippets Groups Projects

Issue #3292989: Remove Ec2OperationsService in the SPA

Files
13
@@ -3,12 +3,10 @@
namespace Drupal\aws_cloud\Controller\Ec2;
use Drupal\aws_cloud\Entity\Ec2\ElasticIp;
use Drupal\aws_cloud\Entity\Ec2\Instance;
use Drupal\aws_cloud\Entity\Ec2\InstanceInterface;
use Drupal\aws_cloud\Entity\Ec2\NetworkInterface;
use Drupal\aws_cloud\Service\AwsCloud\AwsCloudOperationsServiceInterface;
use Drupal\aws_cloud\Service\CloudWatch\CloudWatchServiceInterface;
use Drupal\aws_cloud\Service\Ec2\Ec2OperationsServiceInterface;
use Drupal\aws_cloud\Service\Ec2\Ec2ServiceInterface;
use Drupal\aws_cloud\Traits\AwsCloudEntityCheckTrait;
use Drupal\cloud\Plugin\cloud\config\CloudConfigPluginManagerInterface;
@@ -57,13 +55,6 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
*/
private $ec2Service;
/**
* The AWS Cloud EC2 operation service.
*
* @var \Drupal\aws_cloud\Service\Ec2\Ec2OperationsServiceInterface
*/
private $ec2OperationsService;
/**
* The Messenger service.
*
@@ -134,8 +125,6 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
* The AWS Cloud Operations service.
* @param \Drupal\aws_cloud\Service\Ec2\Ec2ServiceInterface $ec2_service
* Object for interfacing with AWS API.
* @param \Drupal\aws_cloud\Service\Ec2\Ec2OperationsServiceInterface $ec2_operations_service
* The AWS Cloud EC2 operations API service.
* @param \Drupal\Core\Messenger\Messenger $messenger
* Messenger Object.
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
@@ -156,7 +145,6 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
public function __construct(
AwsCloudOperationsServiceInterface $aws_cloud_operations_service,
Ec2ServiceInterface $ec2_service,
Ec2OperationsServiceInterface $ec2_operations_service,
Messenger $messenger,
RequestStack $request_stack,
RendererInterface $renderer,
@@ -168,7 +156,6 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
$this->awsCloudOperationsService = $aws_cloud_operations_service;
$this->ec2Service = $ec2_service;
$this->ec2OperationsService = $ec2_operations_service;
$this->messenger = $messenger;
$this->requestStack = $request_stack;
$this->renderer = $renderer;
@@ -193,7 +180,6 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
return new static(
$container->get('aws_cloud.operations'),
$container->get('aws_cloud.ec2'),
$container->get('aws_cloud.ec2_operations'),
$container->get('messenger'),
$container->get('request_stack'),
$container->get('renderer'),
@@ -744,7 +730,7 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
}
// Execute AWS API.
$result = $this->ec2OperationsService->getConsoleOutput($entity);
$result = $this->awsCloudOperationsService->getConsoleOutput($entity);
return !empty($result)
? new JsonResponse([
@@ -771,37 +757,6 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
return new JsonResponse(['result' => 'OK']);
}
/**
* {@inheritdoc}
*/
public function operateInstance(Request $request, string $cloud_context, string $entity_id, string $command): JsonResponse {
$entity = $command !== 'create'
? $this->getInstanceEntity($entity_id)
: Instance::create();
if (empty($entity)) {
return new JsonResponse([
'result' => 'NG',
'reason' => 'The instance has already been deleted.',
], 404);
}
$result = FALSE;
$method_name = "${command}Instance";
if (method_exists($this->ec2OperationsService, $method_name)) {
$result = $this->ec2OperationsService->$method_name($entity, NULL);
}
return !empty($result)
? new JsonResponse([
'result' => 'OK',
], 200)
: new JsonResponse([
'result' => 'NG',
'reason' => 'Internal Server Error',
], 500);
}
/**
* {@inheritdoc}
*/
Loading