| @@ 7-60 (lines=54) @@ | ||
| 4 | ||
| 5 | use Laravel\Forge\ApiResource; |
|
| 6 | ||
| 7 | class Daemon extends ApiResource |
|
| 8 | { |
|
| 9 | /** |
|
| 10 | * Resource type. |
|
| 11 | * |
|
| 12 | * @return string |
|
| 13 | */ |
|
| 14 | public static function resourceType() |
|
| 15 | { |
|
| 16 | return 'daemon'; |
|
| 17 | } |
|
| 18 | ||
| 19 | /** |
|
| 20 | * Resource path (relative to Server URL). |
|
| 21 | * |
|
| 22 | * @return string |
|
| 23 | */ |
|
| 24 | public function resourcePath() |
|
| 25 | { |
|
| 26 | return 'daemons'; |
|
| 27 | } |
|
| 28 | ||
| 29 | /** |
|
| 30 | * Daemon command. |
|
| 31 | * |
|
| 32 | * @return string|null |
|
| 33 | */ |
|
| 34 | public function command() |
|
| 35 | { |
|
| 36 | return $this->getData('command'); |
|
| 37 | } |
|
| 38 | ||
| 39 | /** |
|
| 40 | * Daemon user. |
|
| 41 | * |
|
| 42 | * @return string|null |
|
| 43 | */ |
|
| 44 | public function user() |
|
| 45 | { |
|
| 46 | return $this->getData('user'); |
|
| 47 | } |
|
| 48 | ||
| 49 | /** |
|
| 50 | * Restart daemon. |
|
| 51 | * |
|
| 52 | * @return bool |
|
| 53 | */ |
|
| 54 | public function restart() |
|
| 55 | { |
|
| 56 | $this->getHttpClient()->request('POST', $this->apiUrl('/restart')); |
|
| 57 | ||
| 58 | return true; |
|
| 59 | } |
|
| 60 | } |
|
| 61 | ||
| @@ 7-60 (lines=54) @@ | ||
| 4 | ||
| 5 | use Laravel\Forge\ApiResource; |
|
| 6 | ||
| 7 | class Recipe extends ApiResource |
|
| 8 | { |
|
| 9 | /** |
|
| 10 | * Resource type. |
|
| 11 | * |
|
| 12 | * @return string |
|
| 13 | */ |
|
| 14 | public static function resourceType() |
|
| 15 | { |
|
| 16 | return 'recipe'; |
|
| 17 | } |
|
| 18 | ||
| 19 | /** |
|
| 20 | * Resource path (relative to Server URL). |
|
| 21 | * |
|
| 22 | * @return string |
|
| 23 | */ |
|
| 24 | public function resourcePath() |
|
| 25 | { |
|
| 26 | return 'recipes'; |
|
| 27 | } |
|
| 28 | ||
| 29 | /** |
|
| 30 | * Recipe user. |
|
| 31 | * |
|
| 32 | * @return string|null |
|
| 33 | */ |
|
| 34 | public function user() |
|
| 35 | { |
|
| 36 | return $this->getData('user'); |
|
| 37 | } |
|
| 38 | ||
| 39 | /** |
|
| 40 | * Recipe script. |
|
| 41 | * |
|
| 42 | * @return string|null |
|
| 43 | */ |
|
| 44 | public function script() |
|
| 45 | { |
|
| 46 | return $this->getData('script'); |
|
| 47 | } |
|
| 48 | ||
| 49 | /** |
|
| 50 | * Run the recipe. |
|
| 51 | * |
|
| 52 | * @return bool |
|
| 53 | */ |
|
| 54 | public function run() |
|
| 55 | { |
|
| 56 | $this->getHttpClient()->request('POST', 'recipes/'.$this->id().'/run'); |
|
| 57 | ||
| 58 | return true; |
|
| 59 | } |
|
| 60 | } |
|
| 61 | ||