From 099e03afef38aa85407d713282f7e52a1f67f561 Mon Sep 17 00:00:00 2001 From: Fodderstompf Date: Sun, 24 Apr 2022 08:45:59 +0100 Subject: [PATCH 1/2] Add nginx configuration resource --- README.md | 11 +++++++ src/Ploi/Resources/NginxConfiguration.php | 39 +++++++++++++++++++++++ src/Ploi/Resources/Site.php | 5 +++ 3 files changed, 55 insertions(+) create mode 100644 src/Ploi/Resources/NginxConfiguration.php diff --git a/README.md b/README.md index 6214cec..7ccb7a2 100644 --- a/README.md +++ b/README.md @@ -366,6 +366,17 @@ $ploi->servers(123)->sites(123)->certificates(123)->get(); $ploi->servers(123)->sites(123)->certificates(123)->delete(); ``` +### NGINX Configuration + +Available methods for NGINX configuration: +```php +// Get NGINX configuration +$ploi->servers(123)->sites(123)->nginxConfiguration()->get(); + +// Update NGINX configuration +$ploi->servers(123)->sites(123)->nginxConfiguration()->update($configuration); +``` + ### Load Balancers Available methods for load balancers diff --git a/src/Ploi/Resources/NginxConfiguration.php b/src/Ploi/Resources/NginxConfiguration.php new file mode 100644 index 0000000..06e90b6 --- /dev/null +++ b/src/Ploi/Resources/NginxConfiguration.php @@ -0,0 +1,39 @@ +getPloi()); + + $this->setSite($site); + + $this->buildEndpoint(); + } + + public function buildEndpoint(): self + { + $this->setEndpoint($this->getSite()->getEndpoint() . '/nginx-configuration'); + + return $this; + } + + public function get(): Response + { + return $this->getPloi()->makeAPICall($this->getEndpoint()); + } + + public function update(string $configuration): Response + { + $options = [ + 'body' => json_encode([ + 'content' => $configuration, + ]), + ]; + return $this->getPloi()->makeAPICall($this->getEndpoint(), 'patch', $options); + } +} \ No newline at end of file diff --git a/src/Ploi/Resources/Site.php b/src/Ploi/Resources/Site.php index 3e91753..61e6987 100644 --- a/src/Ploi/Resources/Site.php +++ b/src/Ploi/Resources/Site.php @@ -297,4 +297,9 @@ public function tenants(): Tenant { return new Tenant($this); } + + public function nginxConfiguration(): NginxConfiguration + { + return new NginxConfiguration($this); + } } From 0379ce5564f0f277b358791aba720c9c4ef9b94e Mon Sep 17 00:00:00 2001 From: Fodderstompf Date: Sun, 24 Apr 2022 09:19:49 +0100 Subject: [PATCH 2/2] Adds laravel horizon statistics method --- README.md | 3 +++ src/Ploi/Resources/Site.php | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index 6214cec..326a1f2 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,9 @@ $ploi->servers(123)->sites(123)->testDomain(); $ploi->servers(123)->sites(123)->suspend($id = null, $reason = null); // Resume site $ploi->servers(123)->sites(123)->resume(); + +// Get Laravel Horizon statistics +$ploi->servers(123)->sites(123)->horizonStatistics($type); ``` ### Databases diff --git a/src/Ploi/Resources/Site.php b/src/Ploi/Resources/Site.php index 3e91753..a2c11eb 100644 --- a/src/Ploi/Resources/Site.php +++ b/src/Ploi/Resources/Site.php @@ -238,6 +238,13 @@ public function resume(int $id = null): Response return $this->getPloi()->makeAPICall($this->getEndpoint() . '/resume', 'post'); } + public function horizonStatistics(string $type): Response + { + $this->buildEndpoint(); + + return $this->getPloi()->makeAPICall($this->getEndpoint() . '/laravel/horizon/' . $type); + } + public function redirects($id = null): Redirect { return new Redirect($this->getServer(), $this, $id);