Skip to content

Commit

Permalink
Fixes #64: Adds support for deleting db backups. (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
typhonius authored Apr 22, 2020
1 parent fbde60e commit b41207e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Endpoints/DatabaseBackups.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
)
);
}
}
14 changes: 14 additions & 0 deletions tests/Endpoints/DatabaseBackupsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
14 changes: 14 additions & 0 deletions tests/Fixtures/Endpoints/DatabaseBackups/deleteDatabaseBackup.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}

0 comments on commit b41207e

Please sign in to comment.