diff --git a/src/Ploi/Resources/AuthUser.php b/src/Ploi/Resources/AuthUser.php index 49ba931..a84f9ca 100644 --- a/src/Ploi/Resources/AuthUser.php +++ b/src/Ploi/Resources/AuthUser.php @@ -44,7 +44,9 @@ public function get(?int $id = null): Response $this->buildEndpoint(); - return $this->getPloi()->makeAPICall($this->getEndpoint()); + return (is_null($this->getId())) + ? $this->page() + : $this->getPloi()->makeAPICall($this->getEndpoint()); } public function create(string $name, string $password): Response diff --git a/src/Ploi/Resources/Certificate.php b/src/Ploi/Resources/Certificate.php index 4af4bb3..bb01f34 100644 --- a/src/Ploi/Resources/Certificate.php +++ b/src/Ploi/Resources/Certificate.php @@ -42,7 +42,9 @@ public function get(int $id = null): Response // Make sure the endpoint is built $this->buildEndpoint(); - return $this->getPloi()->makeAPICall($this->getEndpoint()); + return (is_null($this->getId())) + ? $this->page() + : $this->getPloi()->makeAPICall($this->getEndpoint()); } public function create(string $certificate, string $type = 'letsencrypt'): Response diff --git a/src/Ploi/Resources/Cronjob.php b/src/Ploi/Resources/Cronjob.php index 68dae14..af55e32 100644 --- a/src/Ploi/Resources/Cronjob.php +++ b/src/Ploi/Resources/Cronjob.php @@ -40,7 +40,9 @@ public function get(int $id = null): Response // Make sure the endpoint is built $this->buildEndpoint(); - return $this->getPloi()->makeAPICall($this->getEndpoint()); + return (is_null($this->getId())) + ? $this->page() + : $this->getPloi()->makeAPICall($this->getEndpoint()); } public function create(string $command, string $frequency, string $user = 'ploi'): Response diff --git a/src/Ploi/Resources/Daemon.php b/src/Ploi/Resources/Daemon.php index e1bb7f0..3a58963 100644 --- a/src/Ploi/Resources/Daemon.php +++ b/src/Ploi/Resources/Daemon.php @@ -40,7 +40,9 @@ public function get(int $id = null): Response // Make sure the endpoint is built $this->buildEndpoint(); - return $this->getPloi()->makeAPICall($this->getEndpoint()); + return (is_null($this->getId())) + ? $this->page() + : $this->getPloi()->makeAPICall($this->getEndpoint()); } public function create(string $command, string $systemUser, int $processes, ?string $directory = null): Response diff --git a/src/Ploi/Resources/Database.php b/src/Ploi/Resources/Database.php index 52d4f6e..1ba8218 100644 --- a/src/Ploi/Resources/Database.php +++ b/src/Ploi/Resources/Database.php @@ -44,7 +44,9 @@ public function get(int $id = null): Response // Make sure the endpoint is built $this->buildEndpoint(); - return $this->getPloi()->makeAPICall($this->getEndpoint()); + return (is_null($this->getId())) + ? $this->page() + : $this->getPloi()->makeAPICall($this->getEndpoint()); } public function create(string $name, string $user, string $password, $description = null, $siteId = null): Response diff --git a/src/Ploi/Resources/DatabaseBackup.php b/src/Ploi/Resources/DatabaseBackup.php index 4f4583f..883d96c 100644 --- a/src/Ploi/Resources/DatabaseBackup.php +++ b/src/Ploi/Resources/DatabaseBackup.php @@ -48,7 +48,9 @@ public function get(int $id = null): Response // Make sure the endpoint is built $this->buildEndpoint(); - return $this->getPloi()->makeAPICall($this->getEndpoint()); + return (is_null($this->getId())) + ? $this->page() + : $this->getPloi()->makeAPICall($this->getEndpoint()); } public function create( diff --git a/src/Ploi/Resources/DatabaseUser.php b/src/Ploi/Resources/DatabaseUser.php index 7ce554f..faee700 100644 --- a/src/Ploi/Resources/DatabaseUser.php +++ b/src/Ploi/Resources/DatabaseUser.php @@ -40,7 +40,9 @@ public function get(int $id = null): Response $this->buildEndpoint(); - return $this->getPloi()->makeAPICall($this->getEndpoint()); + return (is_null($this->getId())) + ? $this->page() + : $this->getPloi()->makeAPICall($this->getEndpoint()); } public function create(string $user, string $password): Response diff --git a/src/Ploi/Resources/Incident.php b/src/Ploi/Resources/Incident.php index a915fa9..3c74683 100644 --- a/src/Ploi/Resources/Incident.php +++ b/src/Ploi/Resources/Incident.php @@ -53,7 +53,9 @@ public function get(?int $id = null): Response $this->buildEndpoint(); - return $this->getPloi()->makeAPICall($this->getEndpoint()); + return (is_null($this->getId())) + ? $this->page() + : $this->getPloi()->makeAPICall($this->getEndpoint()); } public function create(string $title, string $description, string $severity): Response diff --git a/src/Ploi/Resources/Insight.php b/src/Ploi/Resources/Insight.php index 25343e5..c41edf8 100644 --- a/src/Ploi/Resources/Insight.php +++ b/src/Ploi/Resources/Insight.php @@ -41,7 +41,9 @@ public function get(?int $id = null): Response $this->buildEndpoint(); - return $this->getPloi()->makeAPICall($this->getEndpoint()); + return (is_null($this->getId())) + ? $this->page() + : $this->getPloi()->makeAPICall($this->getEndpoint()); } public function detail(?int $id = null): Response diff --git a/src/Ploi/Resources/NetworkRule.php b/src/Ploi/Resources/NetworkRule.php index 8e568e1..a807a26 100644 --- a/src/Ploi/Resources/NetworkRule.php +++ b/src/Ploi/Resources/NetworkRule.php @@ -40,7 +40,9 @@ public function get(int $id = null): Response // Make sure the endpoint is built $this->buildEndpoint(); - return $this->getPloi()->makeAPICall($this->getEndpoint()); + return (is_null($this->getId())) + ? $this->page() + : $this->getPloi()->makeAPICall($this->getEndpoint()); } public function create(string $name, int $port, string $type = 'tcp', ?string $fromIpAddress = null, string $ruleType = 'allow'): Response diff --git a/src/Ploi/Resources/Opcache.php b/src/Ploi/Resources/Opcache.php index 95d5cae..fb78129 100644 --- a/src/Ploi/Resources/Opcache.php +++ b/src/Ploi/Resources/Opcache.php @@ -3,13 +3,12 @@ namespace Ploi\Resources; use Ploi\Http\Response; -use Ploi\Traits\HasPagination; class Opcache extends Resource { private $server; - public function __construct(Server $server, int $id = null) + public function __construct(Server $server, ?int $id = null) { parent::__construct($server->getPloi(), $id); diff --git a/src/Ploi/Resources/Queue.php b/src/Ploi/Resources/Queue.php index 6cb7a5d..a7924d1 100644 --- a/src/Ploi/Resources/Queue.php +++ b/src/Ploi/Resources/Queue.php @@ -42,7 +42,9 @@ public function get(int $id = null): Response // Make sure the endpoint is built $this->buildEndpoint(); - return $this->getPloi()->makeAPICall($this->getEndpoint()); + return (is_null($this->getId())) + ? $this->page() + : $this->getPloi()->makeAPICall($this->getEndpoint()); } public function create( diff --git a/src/Ploi/Resources/Redirect.php b/src/Ploi/Resources/Redirect.php index 9843fa8..786f042 100644 --- a/src/Ploi/Resources/Redirect.php +++ b/src/Ploi/Resources/Redirect.php @@ -42,7 +42,9 @@ public function get(int $id = null): Response // Make sure the endpoint is built $this->buildEndpoint(); - return $this->getPloi()->makeAPICall($this->getEndpoint()); + return (is_null($this->getId())) + ? $this->page() + : $this->getPloi()->makeAPICall($this->getEndpoint()); } public function create(string $redirectFrom, string $redirectTo, $type = 'redirect'): Response diff --git a/src/Ploi/Resources/Script.php b/src/Ploi/Resources/Script.php index 0c9d564..20c3a2f 100644 --- a/src/Ploi/Resources/Script.php +++ b/src/Ploi/Resources/Script.php @@ -30,7 +30,9 @@ public function get(int $id = null): Response $this->setEndpoint($this->getEndpoint() . '/' . $this->getId()); } - return $this->getPloi()->makeAPICall($this->getEndpoint()); + return (is_null($this->getId())) + ? $this->page() + : $this->getPloi()->makeAPICall($this->getEndpoint()); } public function create( diff --git a/src/Ploi/Resources/Server.php b/src/Ploi/Resources/Server.php index fb58019..a470c87 100644 --- a/src/Ploi/Resources/Server.php +++ b/src/Ploi/Resources/Server.php @@ -22,7 +22,7 @@ public function __construct(Ploi $ploi = null, int $id = null) public function buildEndpoint(string $path = null): string { - $base = 'servers'; + $base = $this->endpoint; if ($this->getId()) { $base = "{$base}/{$this->getId()}"; @@ -51,7 +51,12 @@ public function get(int $id = null): Response $this->setId($id); } - return $this->callApi(); + // This method do not need the special callApi() method on pagination + // Since its a the simple get of the servers using the $this->endpoint url + + return (is_null($this->getId())) + ? $this->page() + : $this->callApi(); } public function delete(int $id = null): Response diff --git a/src/Ploi/Resources/Site.php b/src/Ploi/Resources/Site.php index 5a47dda..3e91753 100644 --- a/src/Ploi/Resources/Site.php +++ b/src/Ploi/Resources/Site.php @@ -36,7 +36,9 @@ public function get(int $id = null) // Make sure the endpoint is built $this->buildEndpoint(); - return $this->getPloi()->makeAPICall($this->getEndpoint()); + return (is_null($this->getId())) + ? $this->page() + : $this->getPloi()->makeAPICall($this->getEndpoint()); } public function getServer(): Server diff --git a/src/Ploi/Resources/SshKey.php b/src/Ploi/Resources/SshKey.php index e341d87..40c31e2 100644 --- a/src/Ploi/Resources/SshKey.php +++ b/src/Ploi/Resources/SshKey.php @@ -41,7 +41,9 @@ public function get(?int $id = null): Response $this->buildEndpoint(); - return $this->getPloi()->makeAPICall($this->getEndpoint()); + return (is_null($this->getId())) + ? $this->page() + : $this->getPloi()->makeAPICall($this->getEndpoint()); } public function create(string $name, string $key, ?string $systemUser = null): Response diff --git a/src/Ploi/Resources/StatusPage.php b/src/Ploi/Resources/StatusPage.php index 6bc9713..efbbb62 100644 --- a/src/Ploi/Resources/StatusPage.php +++ b/src/Ploi/Resources/StatusPage.php @@ -38,7 +38,9 @@ public function get(?int $id = null): Response $this->buildEndpoint(); - return $this->getPloi()->makeAPICall($this->getEndpoint()); + return (is_null($this->getId())) + ? $this->page() + : $this->getPloi()->makeAPICall($this->getEndpoint()); } public function incident(?int $id = null): Incident diff --git a/src/Ploi/Resources/SystemUser.php b/src/Ploi/Resources/SystemUser.php index c189a8a..ca5995a 100644 --- a/src/Ploi/Resources/SystemUser.php +++ b/src/Ploi/Resources/SystemUser.php @@ -40,7 +40,9 @@ public function get(int $id = null): Response // Make sure the endpoint is built $this->buildEndpoint(); - return $this->getPloi()->makeAPICall($this->getEndpoint()); + return (is_null($this->getId())) + ? $this->page() + : $this->getPloi()->makeAPICall($this->getEndpoint()); } public function create(string $name, bool $sudo = false): Response diff --git a/src/Ploi/Resources/WebserverTemplate.php b/src/Ploi/Resources/WebserverTemplate.php index a04ddab..09a9a3a 100644 --- a/src/Ploi/Resources/WebserverTemplate.php +++ b/src/Ploi/Resources/WebserverTemplate.php @@ -29,6 +29,8 @@ public function get(?int $id = null): Response $this->setEndpoint($this->getEndpoint() . '/' . $this->getId()); } - return $this->getPloi()->makeAPICall($this->getEndpoint()); + return (is_null($this->getId())) + ? $this->page() + : $this->getPloi()->makeAPICall($this->getEndpoint()); } } \ No newline at end of file