Skip to content

Commit e61be98

Browse files
committed
Merge branch 'feature/server-backup-manager'
2 parents 2f4a350 + 32df6dd commit e61be98

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
3+
namespace Timdesm\PterodactylPhpApi\Managers\Server;
4+
5+
use Timdesm\PterodactylPhpApi\Managers\Manager;
6+
use Timdesm\PterodactylPhpApi\Resources\Collection;
7+
use Timdesm\PterodactylPhpApi\Resources\SignedUrl;
8+
use Timdesm\PterodactylPhpApi\Resources\Backup;
9+
10+
class ServerBackupManager extends Manager
11+
{
12+
/**
13+
* Get a paginated collection of backups.
14+
*
15+
* @param mixed $serverId
16+
* @param int $page
17+
* @param array $query
18+
*
19+
* @return Collection
20+
*/
21+
public function paginate($serverId, int $page = 1, array $query = [])
22+
{
23+
return $this->http->get("servers/$serverId/backups", array_merge([
24+
'page' => $page,
25+
], $query));
26+
}
27+
28+
/**
29+
* Get a server instance by id.
30+
*
31+
* @param mixed $serverId
32+
* @param string $backupId
33+
* @param array $query
34+
*
35+
* @return Backup
36+
*/
37+
public function get($serverId, $backupId, array $query = [])
38+
{
39+
return $this->http->get("servers/$serverId/backups/$backupId", $query);
40+
}
41+
42+
/**
43+
* Get download link of the specified backup
44+
*
45+
* @param mixed $serverId
46+
* @param string $backupId
47+
* @param array $query
48+
*
49+
* @return SignedUrl
50+
*/
51+
public function download($serverId, $backupId, array $query = [])
52+
{
53+
return $this->http->get("servers/$serverId/backups/$backupId", $query);
54+
}
55+
56+
/**
57+
* Create a new backup of the specified server
58+
*
59+
* @param mixed $serverId
60+
* @param array $data
61+
*
62+
* @return void
63+
*/
64+
public function create($serverId, $data)
65+
{
66+
return $this->http->post("servers/$serverId/backups", [], $data);
67+
}
68+
69+
/**
70+
* Delete the specified backup
71+
*
72+
* @param mixed $serverId
73+
* @param string $backupId
74+
* @param array $data
75+
*
76+
* @return void
77+
*/
78+
public function delete($serverId, $backupId, $data)
79+
{
80+
return $this->http->delete("servers/$serverId/backups/$backupId", [], $data);
81+
}
82+
}

0 commit comments

Comments
 (0)