Scalr\Api\Service\User\V1beta0\Controller\Servers::rebootAction PHP Method

rebootAction() public method

Reboots instance
public rebootAction ( string $serverId ) : Scalr\Api\DataType\ResultEnvelope
$serverId string UUID of the server
return Scalr\Api\DataType\ResultEnvelope
    public function rebootAction($serverId)
    {
        $server = $this->getServer($serverId);
        $this->checkPermissions($server, Acl::PERM_FARMS_SERVERS);
        if (in_array($server->status, [Server::STATUS_TERMINATED, Server::STATUS_IMPORTING, Server::STATUS_PENDING_LAUNCH, Server::STATUS_PENDING_TERMINATE, Server::STATUS_TEMPORARY])) {
            throw new ApiErrorException(409, ErrorMessage::ERR_UNACCEPTABLE_STATE, sprintf("The Server can't be rebooted in %s state.", $server->status));
        }
        if ($server->platform == SERVER_PLATFORMS::AZURE) {
            throw new ApiNotImplementedErrorException('Reboot action has not been implemented for Azure cloud platform yet.');
        }
        $object = $this->request->getJsonBody();
        $hard = isset($object->hard) ? ServerAdapter::convertInputValue('boolean', $object->hard) : false;
        try {
            $server->reboot($hard);
        } catch (InstanceNotFound $e) {
            throw new ApiErrorException(409, ErrorMessage::ERR_OBJECT_NOT_FOUND_ON_CLOUD, "The Server that you are trying to use does not exist on the cloud.");
        } catch (Exception $e) {
            throw new ApiErrorException(409, ErrorMessage::ERR_UNACCEPTABLE_OBJECT_CONFIGURATION, $e->getMessage());
        }
        $this->response->setStatus(200);
        return $this->result($this->adapter('server')->toData($server));
    }