diff --git a/composer.lock b/composer.lock index ba7afaa..fcdcb7c 100644 --- a/composer.lock +++ b/composer.lock @@ -2470,16 +2470,16 @@ }, { "name": "typhonius/acquia-php-sdk-v2", - "version": "2.0.10", + "version": "2.0.11", "source": { "type": "git", "url": "https://github.com/typhonius/acquia-php-sdk-v2.git", - "reference": "b41207e8458dde482c347519f122f41df3109fdd" + "reference": "6f01d79a77623bfd87dd7629c27ae2c353429fbe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/typhonius/acquia-php-sdk-v2/zipball/b41207e8458dde482c347519f122f41df3109fdd", - "reference": "b41207e8458dde482c347519f122f41df3109fdd", + "url": "https://api.github.com/repos/typhonius/acquia-php-sdk-v2/zipball/6f01d79a77623bfd87dd7629c27ae2c353429fbe", + "reference": "6f01d79a77623bfd87dd7629c27ae2c353429fbe", "shasum": "" }, "require": { @@ -2514,7 +2514,7 @@ } ], "description": "A PHP SDK for Acquia CloudAPI v2", - "time": "2020-04-22T00:27:13+00:00" + "time": "2020-05-07T01:36:47+00:00" } ], "packages-dev": [ diff --git a/src/Commands/SslCertificateCommand.php b/src/Commands/SslCertificateCommand.php index cde48a5..e900ab2 100644 --- a/src/Commands/SslCertificateCommand.php +++ b/src/Commands/SslCertificateCommand.php @@ -70,7 +70,6 @@ public function sslCertificateList( * @command ssl:info */ public function sslCertificateInfo( - OutputInterface $output, SslCertificates $certificatesAdapter, $uuid, $environment, @@ -86,4 +85,52 @@ public function sslCertificateInfo( $this->yell('Private Key'); $this->writeln($certificate->private_key); } + + /** + * Enables an SSL certificate. + * + * @param string $uuid + * @param string $environment + * @param int $certificateId + * + * @command ssl:enable + */ + public function sslCertificateEnable( + SslCertificates $certificatesAdapter, + $uuid, + $environment, + $certificateId + ) { + $environment = $this->cloudapiService->getEnvironment($uuid, $environment); + + if ($this->confirm('Are you sure you want to enable this SSL certificate?')) { + $this->say(sprintf('Enabling certificate on %s environment', $environment->label)); + $response = $certificatesAdapter->enable($environment->uuid, $certificateId); + $this->waitForNotification($response); + } + } + + /** + * Disables an SSL certificate. + * + * @param string $uuid + * @param string $environment + * @param int $certificateId + * + * @command ssl:disable + */ + public function sslCertificateDisable( + SslCertificates $certificatesAdapter, + $uuid, + $environment, + $certificateId + ) { + $environment = $this->cloudapiService->getEnvironment($uuid, $environment); + + if ($this->confirm('Are you sure you want to disable this SSL certificate?')) { + $this->say(sprintf('Disabling certificate on %s environment', $environment->label)); + $response = $certificatesAdapter->disable($environment->uuid, $certificateId); + $this->waitForNotification($response); + } + } } diff --git a/tests/AcquiaCliTestCase.php b/tests/AcquiaCliTestCase.php index ed01c3c..4d40da0 100644 --- a/tests/AcquiaCliTestCase.php +++ b/tests/AcquiaCliTestCase.php @@ -425,6 +425,12 @@ public static function getFixtureMap() ], '/environments/24-a47ac10b-58cc-4372-a567-0e02b2c3d470/ssl/certificates/1234' => [ 'get' => 'SslCertificates/getSslCertificate.json' + ], + '/environments/24-a47ac10b-58cc-4372-a567-0e02b2c3d470/ssl/certificates/1234/actions/activate' => [ + 'post' => 'SslCertificates/activateSslCertificate.json' + ], + '/environments/24-a47ac10b-58cc-4372-a567-0e02b2c3d470/ssl/certificates/1234/actions/deactivate' => [ + 'post' => 'SslCertificates/deactivateSslCertificate.json' ] ]; } diff --git a/tests/Commands/SslCertificateCommandTest.php b/tests/Commands/SslCertificateCommandTest.php index 50350b8..31187c8 100644 --- a/tests/Commands/SslCertificateCommandTest.php +++ b/tests/Commands/SslCertificateCommandTest.php @@ -55,6 +55,14 @@ public function sslCertificateProvider() [ ['ssl:info', 'devcloud:devcloud2', 'dev', '1234'], $infoResponse . PHP_EOL, + ], + [ + ['ssl:enable', 'devcloud:devcloud2', 'dev', '1234'], + '> Enabling certificate on Dev environment' . PHP_EOL, + ], + [ + ['ssl:disable', 'devcloud:devcloud2', 'dev', '1234'], + '> Disabling certificate on Dev environment' . PHP_EOL, ] ]; }