From fc96a47285ec371eb9866344ced76c42e0baeed2 Mon Sep 17 00:00:00 2001 From: Fodderstompf Date: Sun, 24 Apr 2022 08:45:59 +0100 Subject: [PATCH] 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 ee34dc3..1d7093e 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 afa843a..7d33579 100644 --- a/src/Ploi/Resources/Site.php +++ b/src/Ploi/Resources/Site.php @@ -302,4 +302,9 @@ public function monitors(?int $id = null): Monitors { return new Monitors($this, $id); } + + public function nginxConfiguration(): NginxConfiguration + { + return new NginxConfiguration($this); + } }