diff --git a/src/Endpoints/DatabaseBackups.php b/src/Endpoints/DatabaseBackups.php index b5809e69..9576f52a 100644 --- a/src/Endpoints/DatabaseBackups.php +++ b/src/Endpoints/DatabaseBackups.php @@ -100,4 +100,22 @@ public function download($environmentUuid, $dbName, $backupId) "/environments/${environmentUuid}/databases/${dbName}/backups/${backupId}/actions/download" ); } + + /** + * Deletes a database backup. + * + * @param string $environmentUuid + * @param string $dbName + * @param int $backupId + * @return OperationResponse + */ + public function delete($environmentUuid, $dbName, $backupId) + { + return new OperationResponse( + $this->client->request( + 'delete', + "/environments/${environmentUuid}/databases/${dbName}/backups/${backupId}" + ) + ); + } } diff --git a/tests/Endpoints/DatabaseBackupsTest.php b/tests/Endpoints/DatabaseBackupsTest.php index a224160b..611f1831 100644 --- a/tests/Endpoints/DatabaseBackupsTest.php +++ b/tests/Endpoints/DatabaseBackupsTest.php @@ -101,4 +101,18 @@ public function testDownloadDatabaseBackup() $this->assertNotInstanceOf('\ArrayObject', $result); $this->assertInstanceOf('GuzzleHttp\Psr7\Stream', $result); } + + public function testDeleteDatabaseBackup() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/DatabaseBackups/deleteDatabaseBackup.json'); + $client = $this->getMockClient($response); + + /** @var \AcquiaCloudApi\CloudApi\ClientInterface $client */ + $databaseBackup = new DatabaseBackups($client); + $result = $databaseBackup->delete('185f07c7-9c4f-407b-8968-67892ebcb38a', 'db_name', 1234); + + $this->assertInstanceOf('\AcquiaCloudApi\Response\OperationResponse', $result); + + $this->assertEquals('Deleting the database backup.', $result->message); + } } diff --git a/tests/Fixtures/Endpoints/DatabaseBackups/deleteDatabaseBackup.json b/tests/Fixtures/Endpoints/DatabaseBackups/deleteDatabaseBackup.json new file mode 100644 index 00000000..33b7532e --- /dev/null +++ b/tests/Fixtures/Endpoints/DatabaseBackups/deleteDatabaseBackup.json @@ -0,0 +1,14 @@ +{ + "message": "Deleting the database backup.", + "_links": { + "self": { + "href": "https://cloud.acquia.com/api/environments/12-d314739e-296f-11e9-b210-d663bd873d93/databases/my_db/backups/1" + }, + "notification": { + "href": "https://cloud.acquia.com/api/notifications/42b56cff-0b55-4bdf-a949-1fd0fca61c6c" + }, + "parent": { + "href": "https://cloud.acquia.com/api/environments/12-d314739e-296f-11e9-b210-d663bd873d93/databases/my_db/backups" + } + } +} \ No newline at end of file