Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functionality for managing IDEs. #74

Merged
merged 2 commits into from
Apr 11, 2020
Merged
Show file tree
Hide file tree
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
135 changes: 60 additions & 75 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/Cli/AcquiaCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public function injectParameters($container)
$parameterInjection->register('AcquiaCloudApi\Endpoints\Databases', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Endpoints\Domains', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Endpoints\Environments', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Endpoints\Ides', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Endpoints\Insights', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Endpoints\LogForwardingDestinations', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Endpoints\Logs', new AcquiaCliInjector());
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/DbBackupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Symfony\Component\Console\Helper\ProgressBar;

/**
* Class DomainCommand
* Class DbBackupCommand
*
* @package AcquiaCli\Commands
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/DbCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Symfony\Component\Console\Output\BufferedOutput;

/**
* Class DomainCommand
* Class DbCommand
*
* @package AcquiaCli\Commands
*/
Expand Down
77 changes: 77 additions & 0 deletions src/Commands/IdesCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

namespace AcquiaCli\Commands;

use AcquiaCloudApi\Endpoints\Ides;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Helper\TableSeparator;
use Symfony\Component\Console\Helper\TableCell;
use Symfony\Component\Console\Output\BufferedOutput;

/**
* Class IdesCommand
*
* @package AcquiaCli\Commands
*/
class IdesCommand extends AcquiaCommand
{

/**
* Shows all IDEs.
*
* @param string $uuid
*
* @command ide:list
*/
public function list(Ides $idesAdapter, $uuid)
{
$ides = $idesAdapter->getAll($uuid);
$table = new Table($this->output());
$table->setHeaders(['UUID', 'Label']);
foreach ($ides as $ide) {
$table
->addRows(
[
[
$ide->uuid,
$ide->label,
]
]
);
}
$table->render();
}

/**
* Creates an IDE.
*
* @param string $uuid
* @param string $label
*
* @command ide:create
* @aliases ide:add
*/
public function create(Ides $idesAdapter, $uuid, $label)
{
$response = $idesAdapter->create($uuid, $label);
$this->say(sprintf('Creating IDE (%s)', $label));
$this->waitForNotification($response);
}

/**
* De-provisions an IDE.
*
* @param string $ideUuid
*
* @command ide:delete
* @aliases ide:remove
*/
public function delete(Ides $idesAdapter, $ideUuid)
{
if ($this->confirm('Are you sure you want to delete this IDE?')) {
$this->say(sprintf('Deleting IDE (%s)', $ideUuid));
$response = $idesAdapter->delete($ideUuid);
$this->waitForNotification($response);
}
}
}
2 changes: 1 addition & 1 deletion src/Commands/NotificationsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Symfony\Component\Console\Helper\Table;

/**
* Class TasksCommand
* Class NotificationsCommand
*
* @package AcquiaCli\Commands
*/
Expand Down
3 changes: 3 additions & 0 deletions src/Injector/AcquiaCliInjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use AcquiaCloudApi\Endpoints\LogForwardingDestinations;
use AcquiaCloudApi\Endpoints\SslCertificates;
use AcquiaCloudApi\Endpoints\Organizations;
use AcquiaCloudApi\Endpoints\Ides;

class AcquiaCliInjector implements ParameterInjector
{
Expand Down Expand Up @@ -90,6 +91,8 @@ public function get(CommandData $commandData, $interfaceName)
return new SslCertificates($this->client);
case 'AcquiaCloudApi\Endpoints\Organizations':
return new Organizations($this->client);
case 'AcquiaCloudApi\Endpoints\Ides':
return new Ides($this->client);
}
}
}
7 changes: 7 additions & 0 deletions tests/AcquiaCliTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ public static function getFixtureMap()
'/applications/a47ac10b-58cc-4372-a567-0e02b2c3d470/notifications' => [
'get' => 'Notifications/getAllNotifications.json'
],
'/applications/a47ac10b-58cc-4372-a567-0e02b2c3d470/ides' => [
'get' => 'Ides/getAllIdes.json',
'post' => 'Ides/createIde.json'
],
'/environments/24-a47ac10b-58cc-4372-a567-0e02b2c3d470' => [
'delete' => 'Environments/deleteCDEnvironment.json'
],
Expand Down Expand Up @@ -347,6 +351,9 @@ public static function getFixtureMap()
'get' => 'Logs/downloadLog.dat',
'post' => 'Logs/createLogSnapshot.json'
],
'/ides/215824ff-272a-4a8c-9027-df32ed1d68a9' => [
'delete' => 'Ides/deleteIde.json'
],
'/teams/teamUuid/invites' => [
'post' => 'Teams/invite.json'
],
Expand Down
45 changes: 45 additions & 0 deletions tests/Commands/IdesCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace AcquiaCli\Tests\Commands;

use AcquiaCli\Tests\AcquiaCliTestCase;

class IdesCommandTest extends AcquiaCliTestCase
{

/**
* @dataProvider idesProvider
*/
public function testIdesCommands($command, $expected)
{
$actualResponse = $this->execute($command);
$this->assertSame($expected, $actualResponse);
}

public function idesProvider()
{

$idesTable = <<<TABLE
+--------------------------------------+-------------+
| UUID | Label |
+--------------------------------------+-------------+
| 215824ff-272a-4a8c-9027-df32ed1d68a9 | Example IDE |
+--------------------------------------+-------------+
TABLE;

return [
[
['ide:create', 'devcloud:devcloud2', 'Example IDE'],
'> Creating IDE (Example IDE)' . PHP_EOL
],
[
['ide:delete', '215824ff-272a-4a8c-9027-df32ed1d68a9'],
'> Deleting IDE (215824ff-272a-4a8c-9027-df32ed1d68a9)' . PHP_EOL
],
[
['ide:list', 'devcloud:devcloud2'],
$idesTable . PHP_EOL
]
];
}
}