diff --git a/README.md b/README.md index 17bd59c..a9f3534 100644 --- a/README.md +++ b/README.md @@ -129,12 +129,12 @@ $ploi->servers(123)->opcache()->disable(); // Refresh opcache $ploi->servers(123)->opcache()->refresh(); -// Run a one-off script on a server +// Run a one-off script on a server, $content is max 7500 characters and $user defaults to "ploi" $response = $ploi->servers(123)->runOneOffScript('npm install -g pm2', $user = 'deployer'); $executionId = $response->getData()->id; // Poll one-off script execution status and output -$ploi->servers(123)->getScriptExecution($executionId); +$ploi->servers(123)->scriptExecution($executionId); ``` ### Sites @@ -644,7 +644,7 @@ $ploi->scripts(123)->run($id = null, $serverIds = []); $ploi->servers(123)->runOneOffScript($content, $user = null); // Get one-off script execution status -$ploi->servers(123)->getScriptExecution($executionId); +$ploi->servers(123)->scriptExecution($executionId); ``` ### Daemons diff --git a/src/Ploi/Resources/Server.php b/src/Ploi/Resources/Server.php index bbb9dde..35ff514 100644 --- a/src/Ploi/Resources/Server.php +++ b/src/Ploi/Resources/Server.php @@ -231,7 +231,7 @@ public function runOneOffScript(string $content, ?string $user = null): Response ]); } - public function getScriptExecution(string $executionId): Response + public function scriptExecution(string $executionId): Response { $this->setIdOrFail(); diff --git a/tests/Ploi/Resources/ServerTest.php b/tests/Ploi/Resources/ServerTest.php index 976a9f8..6ebceee 100644 --- a/tests/Ploi/Resources/ServerTest.php +++ b/tests/Ploi/Resources/ServerTest.php @@ -31,6 +31,10 @@ public function testBuildsUrlCorrectly() $this->assertEquals('servers/1/endpoint', $server->buildEndpoint('endpoint')); $this->assertEquals('servers/1/endpoint', $server->buildEndpoint('/endpoint')); + $execution = '3f4c9e9a-8b4e-4f0e-9d3b-2f6f2c1a7d42'; + $this->assertEquals('servers/1/scripts/run', $server->buildEndpoint('scripts/run')); + $this->assertEquals("servers/1/scripts/run/{$execution}", $server->buildEndpoint("scripts/run/{$execution}")); + $server->setId(); $this->assertEquals('servers/different-endpoint', $server->buildEndpoint('/different-endpoint')); }