From 2e3331fef40f4ae2155b0e5eaf2d19c2c5c40ded Mon Sep 17 00:00:00 2001 From: Mohamed Said Date: Fri, 9 Nov 2018 09:37:09 +0200 Subject: [PATCH] 2.0 --- composer.json | 2 +- src/Actions/ManagesServers.php | 20 +++++++++++++++++++- src/Actions/ManagesSites.php | 9 +++------ src/Forge.php | 4 ++++ src/Resources/Server.php | 31 +++++++++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 2dd34c6..f0145f6 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "authors": [ { "name": "Mohamed Said", - "email": "themsaid@gmail.com" + "email": "mohamed@laravel.com" } ], "require": { diff --git a/src/Actions/ManagesServers.php b/src/Actions/ManagesServers.php index 48e783a..d4f888b 100644 --- a/src/Actions/ManagesServers.php +++ b/src/Actions/ManagesServers.php @@ -37,7 +37,14 @@ public function server($serverId) */ public function createServer(array $data) { - return new Server($this->post('servers', $data)['server'], $this); + $response = $this->post('servers', $data); + + $output = $response['server']; + $output['sudo_password'] = @$response['sudo_password']; + $output['database_password'] = @$response['database_password']; + $output['provision_command'] = @$response['provision_command']; + + return new Server($output, $this); } /** @@ -173,6 +180,17 @@ public function stopNginx($serverId) $this->post("servers/$serverId/nginx/stop"); } + /** + * Reboot PHP on the server. + * + * @param string $serverId + * @return void + */ + public function rebootPHP($serverId) + { + $this->post("servers/$serverId/php/reboot"); + } + /** * Install Blackfire on the server. * diff --git a/src/Actions/ManagesSites.php b/src/Actions/ManagesSites.php index f64eded..003bf23 100644 --- a/src/Actions/ManagesSites.php +++ b/src/Actions/ManagesSites.php @@ -163,8 +163,7 @@ public function installGitRepositoryOnSite($serverId, $siteId, array $data, $wai if ($wait) { $this->retry($this->getTimeout(), function () use ($serverId, $siteId) { - $site = $this->site($serverId, $siteId); - return $site->repositoryStatus === 'installed'; + return $this->site($serverId, $siteId)->repositoryStatus === 'installed'; }); } } @@ -196,8 +195,7 @@ public function destroySiteGitRepository($serverId, $siteId, $wait = false) if ($wait) { $this->retry($this->getTimeout(), function () use ($serverId, $siteId) { - $site = $this->site($serverId, $siteId); - return is_null($site->repositoryStatus); + return is_null($this->site($serverId, $siteId)->repositoryStatus); }); } } @@ -265,8 +263,7 @@ public function deploySite($serverId, $siteId, $wait = false) if ($wait) { $this->retry($this->getTimeout(), function () use ($serverId, $siteId) { - $site = $this->site($serverId, $siteId); - return is_null($site->deploymentStatus); + return is_null($this->site($serverId, $siteId)->deploymentStatus); }); } } diff --git a/src/Forge.php b/src/Forge.php index fd13f85..39ee2ba 100644 --- a/src/Forge.php +++ b/src/Forge.php @@ -53,6 +53,10 @@ public function __construct($apiKey = null, HttpClient $guzzle = null) if (! is_null($apiKey)) { $this->setApiKey($apiKey, $guzzle); } + + if (! is_null($guzzle)) { + $this->guzzle = $guzzle; + } } /** diff --git a/src/Resources/Server.php b/src/Resources/Server.php index b5e8174..ad22b90 100644 --- a/src/Resources/Server.php +++ b/src/Resources/Server.php @@ -102,6 +102,27 @@ class Server extends Resource */ public $network = []; + /** + * The sudo password of the new server. + * + * @var string + */ + public $sudoPassword; + + /** + * The database password of the new server. + * + * @var string + */ + public $databasePassword; + + /** + * The provision command of the new server. + * + * @var string + */ + public $provisionCommand; + /** * Update the given server. * @@ -223,6 +244,16 @@ public function stopNginx() return $this->forge->stopNginx($this->id); } + /** + * Reboot PHP on the server. + * + * @return void + */ + public function rebootPHP() + { + return $this->forge->rebootPHP($this->id); + } + /** * Install Blackfire on the server. *