diff --git a/composer.lock b/composer.lock index ae10e8f..ee05265 100644 --- a/composer.lock +++ b/composer.lock @@ -1596,6 +1596,57 @@ ], "time": "2019-01-01T16:15:09+00:00" }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.5.4", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "dceec07328401de6211037abbb18bda423677e26" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/dceec07328401de6211037abbb18bda423677e26", + "reference": "dceec07328401de6211037abbb18bda423677e26", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards" + ], + "time": "2020-01-30T22:20:29+00:00" + }, { "name": "symfony/console", "version": "v4.4.5", @@ -1963,20 +2014,6 @@ "redlock", "semaphore" ], - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], "time": "2020-03-27T16:54:36+00:00" }, { @@ -2367,29 +2404,29 @@ }, { "name": "typhonius/acquia-php-sdk-v2", - "version": "2.0.7", + "version": "2.0.8", "source": { "type": "git", "url": "https://github.com/typhonius/acquia-php-sdk-v2.git", - "reference": "dc27d3c9fc08b8af056d24e3605a149caed5d22e" + "reference": "3a5a66b02816ce767ffda7d79e512b57bca1ea46" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/typhonius/acquia-php-sdk-v2/zipball/dc27d3c9fc08b8af056d24e3605a149caed5d22e", - "reference": "dc27d3c9fc08b8af056d24e3605a149caed5d22e", + "url": "https://api.github.com/repos/typhonius/acquia-php-sdk-v2/zipball/3a5a66b02816ce767ffda7d79e512b57bca1ea46", + "reference": "3a5a66b02816ce767ffda7d79e512b57bca1ea46", "shasum": "" }, "require": { "guzzlehttp/guzzle": "^6.3", "league/oauth2-client": "^2.4", - "php": ">=7.1" + "php": ">=7.1", + "squizlabs/php_codesniffer": "3.*" }, "require-dev": { "php-coveralls/php-coveralls": "^2.0.0", "phpstan/phpstan": "^0.11.19", "phpstan/phpstan-phpunit": "^0.11.2", - "phpunit/phpunit": "^7.0", - "squizlabs/php_codesniffer": "^2.7" + "phpunit/phpunit": "^7.0" }, "type": "library", "autoload": { @@ -2411,7 +2448,7 @@ } ], "description": "A PHP SDK for Acquia CloudAPI v2", - "time": "2020-03-08T23:34:06+00:00" + "time": "2020-04-10T22:06:07+00:00" } ], "packages-dev": [ @@ -4725,57 +4762,6 @@ "homepage": "https://github.com/sebastianbergmann/version", "time": "2016-10-03T07:35:21+00:00" }, - { - "name": "squizlabs/php_codesniffer", - "version": "3.5.4", - "source": { - "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "dceec07328401de6211037abbb18bda423677e26" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/dceec07328401de6211037abbb18bda423677e26", - "reference": "dceec07328401de6211037abbb18bda423677e26", - "shasum": "" - }, - "require": { - "ext-simplexml": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" - }, - "bin": [ - "bin/phpcs", - "bin/phpcbf" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Greg Sherwood", - "role": "lead" - } - ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", - "keywords": [ - "phpcs", - "standards" - ], - "time": "2020-01-30T22:20:29+00:00" - }, { "name": "symfony/config", "version": "v4.4.5", @@ -4985,6 +4971,5 @@ "prefer-stable": false, "prefer-lowest": false, "platform": [], - "platform-dev": [], - "plugin-api-version": "1.1.0" + "platform-dev": [] } diff --git a/src/Cli/AcquiaCli.php b/src/Cli/AcquiaCli.php index 1c7555c..61da1be 100644 --- a/src/Cli/AcquiaCli.php +++ b/src/Cli/AcquiaCli.php @@ -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()); diff --git a/src/Commands/DbBackupCommand.php b/src/Commands/DbBackupCommand.php index 2af46a9..2cb94fc 100644 --- a/src/Commands/DbBackupCommand.php +++ b/src/Commands/DbBackupCommand.php @@ -13,7 +13,7 @@ use Symfony\Component\Console\Helper\ProgressBar; /** - * Class DomainCommand + * Class DbBackupCommand * * @package AcquiaCli\Commands */ diff --git a/src/Commands/DbCommand.php b/src/Commands/DbCommand.php index 0c752e8..01c62be 100644 --- a/src/Commands/DbCommand.php +++ b/src/Commands/DbCommand.php @@ -12,7 +12,7 @@ use Symfony\Component\Console\Output\BufferedOutput; /** - * Class DomainCommand + * Class DbCommand * * @package AcquiaCli\Commands */ diff --git a/src/Commands/IdesCommand.php b/src/Commands/IdesCommand.php new file mode 100644 index 0000000..59318c4 --- /dev/null +++ b/src/Commands/IdesCommand.php @@ -0,0 +1,77 @@ +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); + } + } +} diff --git a/src/Commands/NotificationsCommand.php b/src/Commands/NotificationsCommand.php index 33549de..df5840c 100644 --- a/src/Commands/NotificationsCommand.php +++ b/src/Commands/NotificationsCommand.php @@ -9,7 +9,7 @@ use Symfony\Component\Console\Helper\Table; /** - * Class TasksCommand + * Class NotificationsCommand * * @package AcquiaCli\Commands */ diff --git a/src/Injector/AcquiaCliInjector.php b/src/Injector/AcquiaCliInjector.php index 09ccf51..b50cbf5 100644 --- a/src/Injector/AcquiaCliInjector.php +++ b/src/Injector/AcquiaCliInjector.php @@ -24,6 +24,7 @@ use AcquiaCloudApi\Endpoints\LogForwardingDestinations; use AcquiaCloudApi\Endpoints\SslCertificates; use AcquiaCloudApi\Endpoints\Organizations; +use AcquiaCloudApi\Endpoints\Ides; class AcquiaCliInjector implements ParameterInjector { @@ -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); } } } diff --git a/tests/AcquiaCliTestCase.php b/tests/AcquiaCliTestCase.php index ac223b9..bede1cd 100644 --- a/tests/AcquiaCliTestCase.php +++ b/tests/AcquiaCliTestCase.php @@ -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' ], @@ -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' ], diff --git a/tests/Commands/IdesCommandTest.php b/tests/Commands/IdesCommandTest.php new file mode 100644 index 0000000..e0f24c8 --- /dev/null +++ b/tests/Commands/IdesCommandTest.php @@ -0,0 +1,45 @@ +execute($command); + $this->assertSame($expected, $actualResponse); + } + + public function idesProvider() + { + + $idesTable = << 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 + ] + ]; + } +}