2018-03-01 04:51:04 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Requests\Api\Client\Servers;
|
|
|
|
|
2020-03-22 22:31:25 +00:00
|
|
|
use Pterodactyl\Models\Permission;
|
2018-03-01 04:51:04 +00:00
|
|
|
use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
|
|
|
|
|
|
|
|
class SendPowerRequest extends ClientApiRequest
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Determine if the user has permission to send a power command to a server.
|
|
|
|
*/
|
2020-03-22 22:31:25 +00:00
|
|
|
public function permission(): string
|
2018-03-01 04:51:04 +00:00
|
|
|
{
|
2020-03-22 22:31:25 +00:00
|
|
|
switch ($this->input('signal')) {
|
|
|
|
case 'start':
|
|
|
|
return Permission::ACTION_CONTROL_START;
|
|
|
|
case 'stop':
|
2020-03-30 05:12:50 +00:00
|
|
|
case 'kill':
|
2020-03-22 22:31:25 +00:00
|
|
|
return Permission::ACTION_CONTROL_STOP;
|
|
|
|
case 'restart':
|
|
|
|
return Permission::ACTION_CONTROL_RESTART;
|
|
|
|
}
|
|
|
|
|
|
|
|
return '__invalid';
|
2018-03-01 04:51:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-13 14:50:56 +00:00
|
|
|
* Rules to validate this request against.
|
2018-03-01 04:51:04 +00:00
|
|
|
*/
|
|
|
|
public function rules(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'signal' => 'required|string|in:start,stop,restart,kill',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|