Skip to content

Commit

Permalink
Merge pull request #64 from fodderstompf/add-nginx-config-methods
Browse files Browse the repository at this point in the history
Add nginx configuration resource
  • Loading branch information
Cannonb4ll authored Apr 25, 2022
2 parents eb23a84 + fc96a47 commit fb70718
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 39 additions & 0 deletions src/Ploi/Resources/NginxConfiguration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Ploi\Resources;

use Ploi\Http\Response;

class NginxConfiguration extends Resource
{
public function __construct(Site $site)
{
parent::__construct($site->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);
}
}
5 changes: 5 additions & 0 deletions src/Ploi/Resources/Site.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,4 +302,9 @@ public function monitors(?int $id = null): Monitors
{
return new Monitors($this, $id);
}

public function nginxConfiguration(): NginxConfiguration
{
return new NginxConfiguration($this);
}
}

0 comments on commit fb70718

Please sign in to comment.