From b1dd44787bf060f466336f226a8c19fcb5f9577f Mon Sep 17 00:00:00 2001 From: Tim Millwood Date: Thu, 4 Jul 2019 15:43:45 +0100 Subject: [PATCH] Adding modify environment method --- src/CloudApi/Client.php | 24 +++++++++++++++++++ src/CloudApi/ClientInterface.php | 9 +++++++ tests/Endpoints/EnvironmentsTest.php | 14 +++++++++++ .../Fixtures/Endpoints/modifyEnvironment.json | 3 +++ 4 files changed, 50 insertions(+) create mode 100644 tests/Fixtures/Endpoints/modifyEnvironment.json diff --git a/src/CloudApi/Client.php b/src/CloudApi/Client.php index 97ccef47..511fe07a 100644 --- a/src/CloudApi/Client.php +++ b/src/CloudApi/Client.php @@ -558,6 +558,30 @@ public function environment($environmentUuid) ); } + /** + * Modifies configuration settings for an environment. + * + * @param string $environmentUuid + * @param array $config + * @return OperationResponse + */ + public function modifyEnvironment($environmentUuid, array $config) + { + + $options = [ + 'form_params' => $config, + ]; + + return new OperationResponse( + $this->connector->request( + 'put', + "/environments/${environmentUuid}", + $this->query, + $options + ) + ); + } + /** * Renames an environment. * diff --git a/src/CloudApi/ClientInterface.php b/src/CloudApi/ClientInterface.php index a298fe93..3c030612 100644 --- a/src/CloudApi/ClientInterface.php +++ b/src/CloudApi/ClientInterface.php @@ -261,6 +261,15 @@ public function environments($applicationUuid); */ public function environment($environmentUuid); + /** + * Modifies configuration settings for an environment. + * + * @param string $environmentUuid + * @param array $config + * @return OperationResponse + */ + public function modifyEnvironment($environmentUuid, array $config); + /** * Renames an environment. * diff --git a/tests/Endpoints/EnvironmentsTest.php b/tests/Endpoints/EnvironmentsTest.php index 07d41745..fb1deb3e 100644 --- a/tests/Endpoints/EnvironmentsTest.php +++ b/tests/Endpoints/EnvironmentsTest.php @@ -61,6 +61,20 @@ public function testGetEnvironment() } } + public function testModifyEnvironment() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/modifyEnvironment.json'); + + $client = $this->getMockClient($response); + + /** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ + $result = $client->modifyEnvironment('24-a47ac10b-58cc-4372-a567-0e02b2c3d470', ['version' => '7.2']); + + $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + + $this->assertEquals('The environment configuration is being updated.', $result->message); + } + public function testRenameEnvironment() { $response = $this->getPsr7JsonResponseForFixture('Endpoints/renameEnvironment.json'); diff --git a/tests/Fixtures/Endpoints/modifyEnvironment.json b/tests/Fixtures/Endpoints/modifyEnvironment.json new file mode 100644 index 00000000..acab2ea3 --- /dev/null +++ b/tests/Fixtures/Endpoints/modifyEnvironment.json @@ -0,0 +1,3 @@ +{ + "message": "The environment configuration is being updated." +} \ No newline at end of file