Skip to content

Commit d25bdb1

Browse files
authored
Rename getScriptExecution() to scriptExecution() and document API limits (#90)
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".
1 parent 59e5042 commit d25bdb1

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,12 @@ $ploi->servers(123)->opcache()->disable();
129129
// Refresh opcache
130130
$ploi->servers(123)->opcache()->refresh();
131131

132-
// Run a one-off script on a server
132+
// Run a one-off script on a server, $content is max 7500 characters and $user defaults to "ploi"
133133
$response = $ploi->servers(123)->runOneOffScript('npm install -g pm2', $user = 'deployer');
134134
$executionId = $response->getData()->id;
135135

136136
// Poll one-off script execution status and output
137-
$ploi->servers(123)->getScriptExecution($executionId);
137+
$ploi->servers(123)->scriptExecution($executionId);
138138
```
139139

140140
### Sites
@@ -644,7 +644,7 @@ $ploi->scripts(123)->run($id = null, $serverIds = []);
644644
$ploi->servers(123)->runOneOffScript($content, $user = null);
645645

646646
// Get one-off script execution status
647-
$ploi->servers(123)->getScriptExecution($executionId);
647+
$ploi->servers(123)->scriptExecution($executionId);
648648
```
649649

650650
### Daemons

src/Ploi/Resources/Server.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ public function runOneOffScript(string $content, ?string $user = null): Response
231231
]);
232232
}
233233

234-
public function getScriptExecution(string $executionId): Response
234+
public function scriptExecution(string $executionId): Response
235235
{
236236
$this->setIdOrFail();
237237

tests/Ploi/Resources/ServerTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public function testBuildsUrlCorrectly()
3131
$this->assertEquals('servers/1/endpoint', $server->buildEndpoint('endpoint'));
3232
$this->assertEquals('servers/1/endpoint', $server->buildEndpoint('/endpoint'));
3333

34+
$execution = '3f4c9e9a-8b4e-4f0e-9d3b-2f6f2c1a7d42';
35+
$this->assertEquals('servers/1/scripts/run', $server->buildEndpoint('scripts/run'));
36+
$this->assertEquals("servers/1/scripts/run/{$execution}", $server->buildEndpoint("scripts/run/{$execution}"));
37+
3438
$server->setId();
3539
$this->assertEquals('servers/different-endpoint', $server->buildEndpoint('/different-endpoint'));
3640
}

0 commit comments

Comments
 (0)