diff --git a/src/Command/Ide/IdeCreateCommand.php b/src/Command/Ide/IdeCreateCommand.php
index 02f97c04a..4d7ff5f59 100644
--- a/src/Command/Ide/IdeCreateCommand.php
+++ b/src/Command/Ide/IdeCreateCommand.php
@@ -46,7 +46,7 @@ class IdeCreateCommand extends IdeCommandBase {
* {inheritdoc}.
*/
protected function configure() {
- $this->setDescription('Create a Cloud IDE for development');
+ $this->setDescription('Create a Cloud IDE');
$this->acceptApplicationUuid();
$this->addOption('label', NULL, InputOption::VALUE_REQUIRED, 'The label for the IDE');
}
diff --git a/src/Command/Ide/IdeListCommand.php b/src/Command/Ide/IdeListCommand.php
index b475a87d3..357a192c7 100644
--- a/src/Command/Ide/IdeListCommand.php
+++ b/src/Command/Ide/IdeListCommand.php
@@ -13,13 +13,14 @@
*/
class IdeListCommand extends IdeCommandBase {
- protected static $defaultName = 'ide:list';
+ protected static $defaultName = 'ide:list:app';
/**
* {inheritdoc}.
*/
protected function configure() {
- $this->setDescription('List available Cloud IDEs');
+ $this->setDescription('List available Cloud IDEs belonging to a given application');
+ $this->setAliases(['ide:list']);
$this->acceptApplicationUuid();
}
diff --git a/src/Command/Ide/IdeListMineCommand.php b/src/Command/Ide/IdeListMineCommand.php
new file mode 100644
index 000000000..9cedc7661
--- /dev/null
+++ b/src/Command/Ide/IdeListMineCommand.php
@@ -0,0 +1,67 @@
+setDescription('List Cloud IDEs belonging to you');
+ $this->acceptApplicationUuid();
+ }
+
+ /**
+ * @param \Symfony\Component\Console\Input\InputInterface $input
+ * @param \Symfony\Component\Console\Output\OutputInterface $output
+ *
+ * @return int 0 if everything went fine, or an exit code
+ * @throws \Exception
+ */
+ protected function execute(InputInterface $input, OutputInterface $output) {
+ $acquia_cloud_client = $this->cloudApiClientService->getClient();
+ $account_ides = $acquia_cloud_client->request('get', '/account/ides');
+ $application_resource = new Applications($acquia_cloud_client);
+
+ if (count($account_ides)) {
+ $table = new Table($output);
+ $table->setStyle('borderless');
+ $table->setHeaders(['IDEs']);
+ foreach ($account_ides as $ide) {
+ $app_url_parts = explode('/', $ide->_links->application->href);
+ $app_uuid = end($app_url_parts);
+ $application = $application_resource->get($app_uuid);
+ $application_url = str_replace('/api', '/a', $application->links->self->href);
+
+ $table->addRows([
+ ["{$ide->label}"],
+ ["UUID: {$ide->uuid}"],
+ ["Application: {$application->name}>"],
+ ["Subscription: {$application->subscription->name}"],
+ ["IDE URL: _links->ide->href}>{$ide->_links->ide->href}>"],
+ ["Web URL: _links->web->href}>{$ide->_links->web->href}>"],
+ new TableSeparator(),
+ ]);
+ }
+ $table->render();
+ }
+ else {
+ $output->writeln('No IDE exists for your account.');
+ }
+
+ return 0;
+ }
+
+}
diff --git a/tests/phpunit/src/Commands/Ide/IdeListCommandMineTest.php b/tests/phpunit/src/Commands/Ide/IdeListCommandMineTest.php
new file mode 100644
index 000000000..eba7f07e0
--- /dev/null
+++ b/tests/phpunit/src/Commands/Ide/IdeListCommandMineTest.php
@@ -0,0 +1,86 @@
+injectCommand(IdeListMineCommand::class);
+ }
+
+ /**
+ * Tests the 'ide:list-mine' commands.
+ *
+ * @throws \Psr\Cache\InvalidArgumentException
+ */
+ public function testIdeListMineCommand(): void {
+ $applications_response = $this->getMockResponseFromSpec('/applications', 'get', '200');
+ $ides_response = $this->mockAccountIdeListRequest();
+ foreach ($ides_response->{'_embedded'}->items as $key => $ide) {
+ $application_response = $applications_response->{'_embedded'}->items[$key];
+ $app_url_parts = explode('/', $ide->_links->application->href);
+ $app_uuid = end($app_url_parts);
+ $application_response->uuid = $app_uuid;
+ $this->clientProphecy->request('get', '/applications/' . $app_uuid)
+ ->willReturn($application_response)
+ ->shouldBeCalled();
+ }
+
+ $inputs = [
+ // Would you like Acquia CLI to search for a Cloud application that matches your local git config?
+ 'n',
+ // Please select the application.
+ 0,
+ // Would you like to link the project at ... ?
+ 'y',
+ ];
+ $this->executeCommand([], $inputs);
+
+ // Assert.
+ $this->prophet->checkPredictions();
+ $output = $this->getDisplay();
+ $this->assertStringContainsString('IDE Label 1', $output);
+ $this->assertStringContainsString('UUID: 9a83c081-ef78-4dbd-8852-11cc3eb248f7', $output);
+ $this->assertStringContainsString('Application: Sample application 1', $output);
+ $this->assertStringContainsString('Subscription: Sample subscription', $output);
+ $this->assertStringContainsString('IDE URL: https://9a83c081-ef78-4dbd-8852-11cc3eb248f7.ide.ahdev.cloud', $output);
+ $this->assertStringContainsString('Web URL: https://9a83c081-ef78-4dbd-8852-11cc3eb248f7.web.ahdev.cloud', $output);
+
+ $this->assertStringContainsString('IDE Label 2', $output);
+ $this->assertStringContainsString('UUID: 9a83c081-ef78-4dbd-8852-11cc3eb248f7', $output);
+ $this->assertStringContainsString('Application: Sample application 2', $output);
+ $this->assertStringContainsString('Subscription: Sample subscription', $output);
+ $this->assertStringContainsString('IDE URL: https://feea197a-9503-4441-9f49-b4d420b0ecf8.ide.ahdev.cloud', $output);
+ $this->assertStringContainsString('Web URL: https://feea197a-9503-4441-9f49-b4d420b0ecf8.web.ahdev.cloud', $output);
+ }
+
+ /**
+ * @return object
+ * @throws \Psr\Cache\InvalidArgumentException
+ */
+ protected function mockAccountIdeListRequest() {
+ $response = $this->getMockResponseFromSpec('/account/ides',
+ 'get', '200');
+ $this->clientProphecy->request('get',
+ '/account/ides')
+ ->willReturn($response->{'_embedded'}->items)
+ ->shouldBeCalled();
+
+ return $response;
+ }
+
+}