From 8406c43af1ac7c9e91523831729413df390a8e93 Mon Sep 17 00:00:00 2001 From: Dennis Date: Mon, 24 Aug 2026 17:31:47 +0200 Subject: [PATCH] Rename getScriptExecution() to scriptExecution() and document API limits The get* prefix is reserved for accessors on Resource (getId, getPloi, getServer, getEndpoint), which Server inherits. Endpoint-calling methods are noun-only: logs(), monitoring(), phpVersions(). The method was added in #89 after the 2.1 tag, so it is unreleased and can be renamed without a deprecated alias. Also asserts the new endpoints build correctly in testBuildsUrlCorrectly() (the only test that does not hit the live API) and documents that $content is capped at 7500 characters and $user defaults to "ploi". --- README.md | 6 +++--- src/Ploi/Resources/Server.php | 2 +- tests/Ploi/Resources/ServerTest.php | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) 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')); }