Loading modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/aws_cloud/volume.ts 0 → 100644 +76 −0 Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/aws_cloud/volume.ts: 76 added lines, 0 removed lines. Original line number Diff line number Diff line import EntityFormTemplate from 'model/EntityFormTemplate'; const AWS_CLOUD_VOLUME_TEMPLATE: EntityFormTemplate[] = [ { cloudServiceProvider: 'aws_cloud', entityName: 'volume', actionType: 'create', entityRecords: [ { type: 'panel', panelName: 'Volume', keyValueRecords: [ { type: 'default', labelName: 'Name', name: 'name', defaultValue: '' }, { type: 'select', labelName: 'Snapshot ID', name: 'snapshot_id', url: '/cloud_dashboard/aws_cloud/{cloud_context}/volume_snapshot_ids', defaultValue: '', required: true }, { type: 'number', labelName: 'Size (GiB)', name: 'size', defaultValue: 1, required: true }, { type: 'select', labelName: 'Volume type', name: 'volume_type', url: '/cloud_dashboard/aws_cloud/{cloud_context}/volume_types', defaultValue: '', required: true }, { type: 'number', labelName: 'IOPS', name: 'iop', defaultValue: 1 }, { type: 'select', labelName: 'Availability Zone', name: 'availability_zone', url: '/cloud_dashboard/aws_cloud/{cloud_context}/availability_zone', defaultValue: '', required: true }, { type: 'default', labelName: 'KMS key ID', name: 'kms_key_id', defaultValue: '' }, { type: 'boolean', labelName: 'Encrypted', name: 'encrypted', defaultValue: true }, ] } ] }, { cloudServiceProvider: 'aws_cloud', entityName: 'volume', actionType: 'delete', entityRecords: [ { type: 'label', text: 'Are you sure you want to delete the {{entityName}} {{name}}?' }, ], submitButtonLabel: 'Delete' }, { cloudServiceProvider: 'aws_cloud', entityName: 'volume', actionType: 'edit', entityRecords: [ { type: 'panel', panelName: 'Volume', keyValueRecords: [ { type: 'default', labelName: 'Name', name: 'name', defaultValue: '' }, { type: 'default', labelName: 'Volume ID', name: 'volume_id', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Instance ID', name: 'attachment_information', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Snapshot ID', name: 'snapshot_id', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Snapshot Name', name: 'snapshot_name', defaultValue: '', readOnly: true }, { type: 'number', labelName: 'Size (GiB)', name: 'size', defaultValue: 1 }, { type: 'select', labelName: 'Volume type', name: 'volume_type', url: '/cloud_dashboard/aws_cloud/{cloud_context}/volume_types', defaultValue: '', required: true }, { type: 'number', labelName: 'IOPS', name: 'iop', defaultValue: 1 }, { type: 'default', labelName: 'Availability Zone', name: 'availability_zone', defaultValue: '', readOnly: true }, { type: 'boolean', labelName: 'Encrypted', name: 'encrypted', defaultValue: false, labels: ['On', 'Off'], readOnly: true }, { type: 'default', labelName: 'Status', name: 'state', defaultValue: '', readOnly: true }, { type: 'datetime', labelName: 'Created', name: 'created', defaultValue: 0, readOnly: true }, ] } ] }, ] export default AWS_CLOUD_VOLUME_TEMPLATE; modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/entity_form_template.ts +2 −0 Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/entity_form_template.ts: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ import AWS_CLOUD_SUBNET_TEMPLATE from 'constant/form_template/aws_cloud/subnet'; import AWS_CLOUD_TRANSIT_GATEWAY_TEMPLATE from 'constant/form_template/aws_cloud/transit_gateway'; import AWS_CLOUD_VPC_TEMPLATE from 'constant/form_template/aws_cloud/vpc'; import AWS_CLOUD_VPC_PEERING_CONNECTION from "constant/form_template/aws_cloud/vpc_peering_connection"; import AWS_CLOUD_VOLUME_TEMPLATE from "constant/form_template/aws_cloud/volume"; import K8S_DEPLOYMENT_TEMPLATE from 'constant/form_template/k8s/deployment'; import K8S_NAMESPACE_TEMPLATE from 'constant/form_template/k8s/namespace'; import K8S_OTHER_TEMPLATE from 'constant/form_template/k8s/other'; Loading Loading @@ -40,6 +41,7 @@ const ENTITY_FORM_LIST = [ ...AWS_CLOUD_VPC_PEERING_CONNECTION, ...AWS_CLOUD_SUBNET_TEMPLATE, ...AWS_CLOUD_SNAPSHOT, ...AWS_CLOUD_VOLUME_TEMPLATE, ...K8S_DEPLOYMENT_TEMPLATE, ...K8S_NAMESPACE_TEMPLATE, ...K8S_POD_TEMPLATE, Loading modules/cloud_service_providers/aws_cloud/aws_cloud.routing.yml +65 −0 Changes for modules/cloud_service_providers/aws_cloud/aws_cloud.routing.yml: 65 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -1566,3 +1566,68 @@ entity.aws_cloud_snapshot.delete: _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access' options: perm: 'delete any aws cloud snapshot+delete own aws cloud snapshot' entity.aws_cloud_volume.create: path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_volume/create' defaults: _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::operateEntity' entity_type_id: aws_cloud_volume entity_id: '' command: create methods: [POST] requirements: # Use custom access that will check for cloud_context and the desired permission. # Desired permission is passed as an option in the "perm" variable _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access' options: perm: 'add aws cloud volume' entity.aws_cloud_volume.volume_snapshot_ids: path: '/cloud_dashboard/aws_cloud/{cloud_context}/volume_snapshot_ids' defaults: _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::getSnapshotOptions' requirements: # Use custom access that will check for cloud_context and the desired permission. # Desired permission is passed as an option in the "perm" variable _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access' options: perm: 'add aws cloud volume' entity.aws_cloud_volume.volume_types: path: '/cloud_dashboard/aws_cloud/{cloud_context}/volume_types' defaults: _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::getVolumeTypes' requirements: # Use custom access that will check for cloud_context and the desired permission. # Desired permission is passed as an option in the "perm" variable _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access' options: perm: 'add aws cloud volume' entity.aws_cloud_volume.delete: path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_volume/{entity_id}/delete' defaults: _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::operateEntity' entity_type_id: aws_cloud_volume command: delete methods: [POST] requirements: # Use custom access that will check for cloud_context and the desired permission. # Desired permission is passed as an option in the "perm" variable _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access' options: perm: 'delete any aws cloud volume+delete own aws cloud volume' entity.aws_cloud_volume.edit: path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_volume/{entity_id}/edit' defaults: _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::operateEntity' entity_type_id: aws_cloud_volume command: edit methods: [POST] requirements: # Use custom access that will check for cloud_context and the desired permission. # Desired permission is passed as an option in the "perm" variable _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access' options: perm: 'edit any aws cloud volume+edit own aws cloud volume' modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/ApiController.php +80 −0 Changes for modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/ApiController.php: 80 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -938,6 +938,19 @@ class ApiController extends ControllerBase implements ApiControllerInterface { $method_name = 'createSnapshot'; break; case 'create_aws_cloud_volume': /** @var \Drupal\aws_cloud\Entity\Ec2\VolumeInterface $entity */ $entity->setName($request->get('name', '')); $entity->setSnapshotId($request->get('snapshot_id', '')); $entity->setSize($request->get('size', '')); $entity->setVolumeType($request->get('volume_type', '')); $entity->setIops($request->get('iop', '')); $entity->set('availability_zone', $request->get('availability_zone', '')); $entity->set('kms_key_id', $request->get('kms_key_id', '')); $entity->set('encrypted', $request->get('encrypted', '')); $method_name = 'createVolume'; break; case 'delete_aws_cloud_elastic_ip': $method_name = 'deleteElasticIp'; break; Loading @@ -962,6 +975,10 @@ class ApiController extends ControllerBase implements ApiControllerInterface { $method_name = 'deleteSnapshot'; break; case 'delete_aws_cloud_volume': $method_name = 'deleteVolume'; break; case 'disassociate_aws_cloud_elastic_ip': $method_name = 'disassociateElasticIp'; break; Loading Loading @@ -1030,6 +1047,15 @@ class ApiController extends ControllerBase implements ApiControllerInterface { $method_name = 'editSnapshot'; break; case 'edit_aws_cloud_volume': /** @var \Drupal\aws_cloud\Entity\Ec2\VolumeInterface $entity */ $entity->setName($request->get('name', '')); $entity->setSize($request->get('size', '')); $entity->setVolumeType($request->get('volume_type', '')); $entity->setIops($request->get('iop', '')); $method_name = 'editVolume'; break; case 'import_aws_cloud_key_pair': /** @var \Drupal\aws_cloud\Entity\Ec2\KeyPairInterface $entity */ $entity->set('key_pair_name', $request->get('key_pair_name', '')); Loading Loading @@ -1731,4 +1757,58 @@ class ApiController extends ControllerBase implements ApiControllerInterface { return new JsonResponse($options); } /** * {@inheritdoc} */ public function getSnapshotOptions($cloud_context): JsonResponse { $options = []; $params = [ 'cloud_context' => $cloud_context, ]; if (!$this->currentUser->hasPermission('view any aws clcoud snapshot')) { $params['uid'] = $this->currentUser->id(); } $snapshots = $this->entityTypeManager ->getStorage('aws_cloud_snapshot') ->loadByProperties($params); foreach ($snapshots ?: [] as $snapshot) { $options[] = [ 'value' => $snapshot->getSnapshotId(), 'label' => $snapshot->getName() !== $snapshot->getSnapshotId() ? "{$snapshot->getName()} ({$snapshot->getSnapshotId()})" : $snapshot->getSnapshotId(), ]; } return new JsonResponse($options); } /** * {@inheritdoc} */ public function getVolumeTypes($cloud_context): JsonResponse { $dummy_options = [ 'gp2' => $this->t('General Purpose SSD (gp2)'), 'gp3' => $this->t('General Purpose SSD (gp3)'), 'io1' => $this->t('Provisioned IOPS SSD (io1)'), 'io2' => $this->t('Provisioned IOPS SSD (io2)'), 'sc1' => $this->t('Cold HDD (sc1)'), 'st1' => $this->t('Throughput Optimized HDD (st1)'), 'standard' => $this->t('Magnetic (standard)'), ]; $options = []; foreach ($dummy_options ?: [] as $key => $option) { $options[] = [ 'value' => $key, 'label' => $option, ]; } return new JsonResponse($options); } } modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/ApiControllerInterface.php +28 −0 Changes for modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/ApiControllerInterface.php: 28 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -318,4 +318,32 @@ interface ApiControllerInterface { */ public function getVolumeOptions($cloud_context): JsonResponse; /** * Helper function to get snapshot options. * * @param string $cloud_context * Cloud context to use in the query. * * @return \Symfony\Component\HttpFoundation\JsonResponse * The JSON response. * * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException */ public function getSnapshotOptions($cloud_context): JsonResponse; /** * Helper function to get volume types. * * @param string $cloud_context * Cloud context to use in the query. * * @return \Symfony\Component\HttpFoundation\JsonResponse * The JSON response. * * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException */ public function getVolumeTypes($cloud_context): JsonResponse; } Loading
modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/aws_cloud/volume.ts 0 → 100644 +76 −0 Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/aws_cloud/volume.ts: 76 added lines, 0 removed lines. Original line number Diff line number Diff line import EntityFormTemplate from 'model/EntityFormTemplate'; const AWS_CLOUD_VOLUME_TEMPLATE: EntityFormTemplate[] = [ { cloudServiceProvider: 'aws_cloud', entityName: 'volume', actionType: 'create', entityRecords: [ { type: 'panel', panelName: 'Volume', keyValueRecords: [ { type: 'default', labelName: 'Name', name: 'name', defaultValue: '' }, { type: 'select', labelName: 'Snapshot ID', name: 'snapshot_id', url: '/cloud_dashboard/aws_cloud/{cloud_context}/volume_snapshot_ids', defaultValue: '', required: true }, { type: 'number', labelName: 'Size (GiB)', name: 'size', defaultValue: 1, required: true }, { type: 'select', labelName: 'Volume type', name: 'volume_type', url: '/cloud_dashboard/aws_cloud/{cloud_context}/volume_types', defaultValue: '', required: true }, { type: 'number', labelName: 'IOPS', name: 'iop', defaultValue: 1 }, { type: 'select', labelName: 'Availability Zone', name: 'availability_zone', url: '/cloud_dashboard/aws_cloud/{cloud_context}/availability_zone', defaultValue: '', required: true }, { type: 'default', labelName: 'KMS key ID', name: 'kms_key_id', defaultValue: '' }, { type: 'boolean', labelName: 'Encrypted', name: 'encrypted', defaultValue: true }, ] } ] }, { cloudServiceProvider: 'aws_cloud', entityName: 'volume', actionType: 'delete', entityRecords: [ { type: 'label', text: 'Are you sure you want to delete the {{entityName}} {{name}}?' }, ], submitButtonLabel: 'Delete' }, { cloudServiceProvider: 'aws_cloud', entityName: 'volume', actionType: 'edit', entityRecords: [ { type: 'panel', panelName: 'Volume', keyValueRecords: [ { type: 'default', labelName: 'Name', name: 'name', defaultValue: '' }, { type: 'default', labelName: 'Volume ID', name: 'volume_id', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Instance ID', name: 'attachment_information', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Snapshot ID', name: 'snapshot_id', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Snapshot Name', name: 'snapshot_name', defaultValue: '', readOnly: true }, { type: 'number', labelName: 'Size (GiB)', name: 'size', defaultValue: 1 }, { type: 'select', labelName: 'Volume type', name: 'volume_type', url: '/cloud_dashboard/aws_cloud/{cloud_context}/volume_types', defaultValue: '', required: true }, { type: 'number', labelName: 'IOPS', name: 'iop', defaultValue: 1 }, { type: 'default', labelName: 'Availability Zone', name: 'availability_zone', defaultValue: '', readOnly: true }, { type: 'boolean', labelName: 'Encrypted', name: 'encrypted', defaultValue: false, labels: ['On', 'Off'], readOnly: true }, { type: 'default', labelName: 'Status', name: 'state', defaultValue: '', readOnly: true }, { type: 'datetime', labelName: 'Created', name: 'created', defaultValue: 0, readOnly: true }, ] } ] }, ] export default AWS_CLOUD_VOLUME_TEMPLATE;
modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/entity_form_template.ts +2 −0 Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/entity_form_template.ts: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ import AWS_CLOUD_SUBNET_TEMPLATE from 'constant/form_template/aws_cloud/subnet'; import AWS_CLOUD_TRANSIT_GATEWAY_TEMPLATE from 'constant/form_template/aws_cloud/transit_gateway'; import AWS_CLOUD_VPC_TEMPLATE from 'constant/form_template/aws_cloud/vpc'; import AWS_CLOUD_VPC_PEERING_CONNECTION from "constant/form_template/aws_cloud/vpc_peering_connection"; import AWS_CLOUD_VOLUME_TEMPLATE from "constant/form_template/aws_cloud/volume"; import K8S_DEPLOYMENT_TEMPLATE from 'constant/form_template/k8s/deployment'; import K8S_NAMESPACE_TEMPLATE from 'constant/form_template/k8s/namespace'; import K8S_OTHER_TEMPLATE from 'constant/form_template/k8s/other'; Loading Loading @@ -40,6 +41,7 @@ const ENTITY_FORM_LIST = [ ...AWS_CLOUD_VPC_PEERING_CONNECTION, ...AWS_CLOUD_SUBNET_TEMPLATE, ...AWS_CLOUD_SNAPSHOT, ...AWS_CLOUD_VOLUME_TEMPLATE, ...K8S_DEPLOYMENT_TEMPLATE, ...K8S_NAMESPACE_TEMPLATE, ...K8S_POD_TEMPLATE, Loading
modules/cloud_service_providers/aws_cloud/aws_cloud.routing.yml +65 −0 Changes for modules/cloud_service_providers/aws_cloud/aws_cloud.routing.yml: 65 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -1566,3 +1566,68 @@ entity.aws_cloud_snapshot.delete: _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access' options: perm: 'delete any aws cloud snapshot+delete own aws cloud snapshot' entity.aws_cloud_volume.create: path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_volume/create' defaults: _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::operateEntity' entity_type_id: aws_cloud_volume entity_id: '' command: create methods: [POST] requirements: # Use custom access that will check for cloud_context and the desired permission. # Desired permission is passed as an option in the "perm" variable _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access' options: perm: 'add aws cloud volume' entity.aws_cloud_volume.volume_snapshot_ids: path: '/cloud_dashboard/aws_cloud/{cloud_context}/volume_snapshot_ids' defaults: _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::getSnapshotOptions' requirements: # Use custom access that will check for cloud_context and the desired permission. # Desired permission is passed as an option in the "perm" variable _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access' options: perm: 'add aws cloud volume' entity.aws_cloud_volume.volume_types: path: '/cloud_dashboard/aws_cloud/{cloud_context}/volume_types' defaults: _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::getVolumeTypes' requirements: # Use custom access that will check for cloud_context and the desired permission. # Desired permission is passed as an option in the "perm" variable _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access' options: perm: 'add aws cloud volume' entity.aws_cloud_volume.delete: path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_volume/{entity_id}/delete' defaults: _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::operateEntity' entity_type_id: aws_cloud_volume command: delete methods: [POST] requirements: # Use custom access that will check for cloud_context and the desired permission. # Desired permission is passed as an option in the "perm" variable _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access' options: perm: 'delete any aws cloud volume+delete own aws cloud volume' entity.aws_cloud_volume.edit: path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_volume/{entity_id}/edit' defaults: _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::operateEntity' entity_type_id: aws_cloud_volume command: edit methods: [POST] requirements: # Use custom access that will check for cloud_context and the desired permission. # Desired permission is passed as an option in the "perm" variable _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access' options: perm: 'edit any aws cloud volume+edit own aws cloud volume'
modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/ApiController.php +80 −0 Changes for modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/ApiController.php: 80 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -938,6 +938,19 @@ class ApiController extends ControllerBase implements ApiControllerInterface { $method_name = 'createSnapshot'; break; case 'create_aws_cloud_volume': /** @var \Drupal\aws_cloud\Entity\Ec2\VolumeInterface $entity */ $entity->setName($request->get('name', '')); $entity->setSnapshotId($request->get('snapshot_id', '')); $entity->setSize($request->get('size', '')); $entity->setVolumeType($request->get('volume_type', '')); $entity->setIops($request->get('iop', '')); $entity->set('availability_zone', $request->get('availability_zone', '')); $entity->set('kms_key_id', $request->get('kms_key_id', '')); $entity->set('encrypted', $request->get('encrypted', '')); $method_name = 'createVolume'; break; case 'delete_aws_cloud_elastic_ip': $method_name = 'deleteElasticIp'; break; Loading @@ -962,6 +975,10 @@ class ApiController extends ControllerBase implements ApiControllerInterface { $method_name = 'deleteSnapshot'; break; case 'delete_aws_cloud_volume': $method_name = 'deleteVolume'; break; case 'disassociate_aws_cloud_elastic_ip': $method_name = 'disassociateElasticIp'; break; Loading Loading @@ -1030,6 +1047,15 @@ class ApiController extends ControllerBase implements ApiControllerInterface { $method_name = 'editSnapshot'; break; case 'edit_aws_cloud_volume': /** @var \Drupal\aws_cloud\Entity\Ec2\VolumeInterface $entity */ $entity->setName($request->get('name', '')); $entity->setSize($request->get('size', '')); $entity->setVolumeType($request->get('volume_type', '')); $entity->setIops($request->get('iop', '')); $method_name = 'editVolume'; break; case 'import_aws_cloud_key_pair': /** @var \Drupal\aws_cloud\Entity\Ec2\KeyPairInterface $entity */ $entity->set('key_pair_name', $request->get('key_pair_name', '')); Loading Loading @@ -1731,4 +1757,58 @@ class ApiController extends ControllerBase implements ApiControllerInterface { return new JsonResponse($options); } /** * {@inheritdoc} */ public function getSnapshotOptions($cloud_context): JsonResponse { $options = []; $params = [ 'cloud_context' => $cloud_context, ]; if (!$this->currentUser->hasPermission('view any aws clcoud snapshot')) { $params['uid'] = $this->currentUser->id(); } $snapshots = $this->entityTypeManager ->getStorage('aws_cloud_snapshot') ->loadByProperties($params); foreach ($snapshots ?: [] as $snapshot) { $options[] = [ 'value' => $snapshot->getSnapshotId(), 'label' => $snapshot->getName() !== $snapshot->getSnapshotId() ? "{$snapshot->getName()} ({$snapshot->getSnapshotId()})" : $snapshot->getSnapshotId(), ]; } return new JsonResponse($options); } /** * {@inheritdoc} */ public function getVolumeTypes($cloud_context): JsonResponse { $dummy_options = [ 'gp2' => $this->t('General Purpose SSD (gp2)'), 'gp3' => $this->t('General Purpose SSD (gp3)'), 'io1' => $this->t('Provisioned IOPS SSD (io1)'), 'io2' => $this->t('Provisioned IOPS SSD (io2)'), 'sc1' => $this->t('Cold HDD (sc1)'), 'st1' => $this->t('Throughput Optimized HDD (st1)'), 'standard' => $this->t('Magnetic (standard)'), ]; $options = []; foreach ($dummy_options ?: [] as $key => $option) { $options[] = [ 'value' => $key, 'label' => $option, ]; } return new JsonResponse($options); } }
modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/ApiControllerInterface.php +28 −0 Changes for modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/ApiControllerInterface.php: 28 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -318,4 +318,32 @@ interface ApiControllerInterface { */ public function getVolumeOptions($cloud_context): JsonResponse; /** * Helper function to get snapshot options. * * @param string $cloud_context * Cloud context to use in the query. * * @return \Symfony\Component\HttpFoundation\JsonResponse * The JSON response. * * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException */ public function getSnapshotOptions($cloud_context): JsonResponse; /** * Helper function to get volume types. * * @param string $cloud_context * Cloud context to use in the query. * * @return \Symfony\Component\HttpFoundation\JsonResponse * The JSON response. * * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException */ public function getVolumeTypes($cloud_context): JsonResponse; }