From 099e03afef38aa85407d713282f7e52a1f67f561 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 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); + } }