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

suspendAction() public method

Stops instance
public suspendAction ( string $serverId ) : Scalr\Api\DataType\ResultEnvelope
$serverId string UUID of the server
return Scalr\Api\DataType\ResultEnvelope
    public function suspendAction($serverId)
    {
        $server = $this->getServer($serverId);
        $this->checkPermissions($server, Acl::PERM_FARMS_SERVERS);
        if ($server->platform == SERVER_PLATFORMS::EC2) {
            $image = $server->getImage();
            if (!empty($image) && $image->isEc2InstanceStoreImage()) {
                throw new ApiErrorException(409, ErrorMessage::ERR_CONFIGURATION_MISMATCH, "The instance does not have an 'ebs' root device type and cannot be suspended");
            }
        }
        $farmRole = $server->getFarmRole();
        if (!empty($farmRole)) {
            $role = $farmRole->getRole();
            if ($role->hasDbBehavior()) {
                throw new ApiErrorException(409, ErrorMessage::ERR_CONFIGURATION_MISMATCH, "Instance with database built in automation can not be stopped");
            }
            if ($role->hasBehavior(ROLE_BEHAVIORS::RABBITMQ)) {
                throw new ApiErrorException(409, ErrorMessage::ERR_CONFIGURATION_MISMATCH, "Instance with rabbitmq built in automation can not be stopped");
            }
        }
        if (!$server->suspend($this->getUser())) {
            throw new ApiErrorException(409, ErrorMessage::ERR_UNACCEPTABLE_STATE, "Only Running Servers can be suspended.");
        }
        $this->response->setStatus(200);
        return $this->result($this->adapter('server')->toData($server));
    }