Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions src/Command/Ide/IdeListMineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Acquia\Cli\Attribute\RequireAuth;
use AcquiaCloudApi\Endpoints\Applications;
use AcquiaCloudApi\Endpoints\Codebases;
use AcquiaCloudApi\Endpoints\Ides;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
Expand All @@ -23,23 +24,39 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$acquiaCloudClient = $this->cloudApiClientService->getClient();
$ides = new Ides($acquiaCloudClient);
$accountIdes = $ides->getMine();
$codebaseResource = new Codebases($acquiaCloudClient);
$applicationResource = new Applications($acquiaCloudClient);

if (count($accountIdes)) {
$table = new Table($output);
$table->setStyle('borderless');
$table->setHeaders(['IDEs']);
foreach ($accountIdes as $ide) {
$appUrlParts = explode('/', $ide->links->application->href);
$appUuid = end($appUrlParts);
$application = $applicationResource->get($appUuid);
$applicationUrl = str_replace('/api', '/a', $application->links->self->href);
if (isset($ide->links->application)) {
$sub = "Application";
$appUrlParts = explode('/', $ide->links->application->href);
$appUuid = end($appUrlParts);
$application = $applicationResource->get($appUuid);
$name = $application->name;
$url = str_replace('/api', '/a', $ide->links->application->href);
} elseif (isset($ide->links->codebase)) {
$sub = "Codebase";
$codebaseUrlParts = explode('/', $ide->links->codebase->href);
$codebaseUuid = end($codebaseUrlParts);
$codebase = $codebaseResource->get($codebaseUuid);
$name = $codebase->label;
$url = str_replace('/api', '/a', $ide->links->codebase->href);
} else {
$name = 'N/A';
$url = 'N/A';
$sub = 'N/A';
}

$table->addRows([
["<comment>$ide->label</comment>"],
["UUID: $ide->uuid"],
["Application: <href=$applicationUrl>$application->name</>"],
["Subscription: {$application->subscription->name}"],
["$sub: <href=$url>$name</>"],
["Subscription: {$name}"],
["IDE URL: <href={$ide->links->ide->href}>{$ide->links->ide->href}</>"],
["Web URL: <href={$ide->links->web->href}>{$ide->links->web->href}</>"],
new TableSeparator(),
Expand Down
Loading