Skip to content

Commit

Permalink
Merge pull request #57 from fodderstompf/add-database-duplicate
Browse files Browse the repository at this point in the history
Add duplicate method to database resource
  • Loading branch information
Cannonb4ll authored Mar 7, 2022
2 parents 77674e8 + d4af321 commit a0ac4ac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ $ploi->servers(123)->databases()->acknowledge($databaseName);

// Forget database
$ploi->servers(123)->databases(123)->forget();

// Duplicate database
$ploi->servers(123)->databases(123)->duplicate($name, $user = null, $password = null);
```

### Database Backups
Expand Down
15 changes: 15 additions & 0 deletions src/Ploi/Resources/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,21 @@ public function forget(int $id = null): Response
return $this->getPloi()->makeAPICall($this->getEndpoint(), 'delete');
}

public function duplicate(string $name, string $user = null, string $password = null): Response
{
$this->setIdOrFail();

$options = [
'body' => json_encode([
'name' => $name,
'user' => $user,
'password' => $password,
]),
];

return $this->getPloi()->makeAPICall($this->getEndpoint() . '/duplicate', 'post', $options);
}

public function backups($id = null): DatabaseBackup
{
return new DatabaseBackup($this->getServer(),$this,$id);
Expand Down

0 comments on commit a0ac4ac

Please sign in to comment.