Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
| StartupScriptService | |
100.00% |
5 / 5 |
|
100.00% |
5 / 5 |
5 | |
100.00% |
1 / 1 |
| getStartupScript | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getStartupScripts | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| createStartupScript | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| updateStartupScript | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| deleteStartupScript | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Vultr\VultrPhp\Services\StartupScripts; |
| 6 | |
| 7 | use Vultr\VultrPhp\Services\VultrService; |
| 8 | use Vultr\VultrPhp\Util\ListOptions; |
| 9 | |
| 10 | /** |
| 11 | * Startup script service handler, for all startup-scripts endpoints. |
| 12 | * |
| 13 | * @see https://www.vultr.com/api/#tag/startup |
| 14 | */ |
| 15 | class StartupScriptService extends VultrService |
| 16 | { |
| 17 | /** |
| 18 | * @param $startup_id - string - UUID of the startup script |
| 19 | * @throws StartupScriptException |
| 20 | * @throws VultrException |
| 21 | * @return StartupScript |
| 22 | */ |
| 23 | public function getStartupScript(string $startup_id) : StartupScript |
| 24 | { |
| 25 | return $this->getObject('startup-scripts/'.$startup_id, new StartupScript()); |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * @param $options - ListOptions - Interact via reference. |
| 30 | * @throws StartupScriptException |
| 31 | * @return StartupScript[] |
| 32 | */ |
| 33 | public function getStartupScripts(?ListOptions &$options = null) : array |
| 34 | { |
| 35 | return $this->getListObjects('startup-scripts', new StartupScript(), $options); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * @param $script - StartupScript Model with any properties defined will be used in the response. |
| 40 | * @throws StartupScriptException |
| 41 | * @throws VultrException |
| 42 | * @return StartupScript |
| 43 | */ |
| 44 | public function createStartupScript(StartupScript $script) : StartupScript |
| 45 | { |
| 46 | return $this->createObject('startup-scripts', new StartupScript(), $script->getInitializedProps()); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * @param $script - StartupScript |
| 51 | * @throws StartupScriptException |
| 52 | * @return void |
| 53 | */ |
| 54 | public function updateStartupScript(StartupScript $script) : void |
| 55 | { |
| 56 | $this->patchObject('startup-scripts/'.$script->getId(), $script); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * @param $startup_id - string |
| 61 | * @throws StartupScriptException |
| 62 | * @return void |
| 63 | */ |
| 64 | public function deleteStartupScript(string $startup_id) : void |
| 65 | { |
| 66 | $this->deleteObject('startup-scripts/'.$startup_id, new StartupScript()); |
| 67 | } |
| 68 | } |
| 69 |