-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add functionality for managing IDEs. (#74)
* Add functionality for managing IDEs. * Updates acquia-php-sdk-v2 to 2.0.8.
- Loading branch information
Showing
9 changed files
with
196 additions
and
78 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
] | ||
]; | ||
} | ||
} |