Scalr\Api\Service\User\V1beta0\Controller\Farms::modifyVariableAction PHP Method

modifyVariableAction() public method

Modifies farm's global variable
public modifyVariableAction ( integer $farmId, string $name ) : Scalr\Api\DataType\ResultEnvelope
$farmId integer Numeric identifier of the Farm
$name string Name of variable
return Scalr\Api\DataType\ResultEnvelope
    public function modifyVariableAction($farmId, $name)
    {
        $this->getFarm($farmId, Acl::PERM_FARMS_UPDATE);
        $object = $this->request->getJsonBody();
        /* @var  $adapter GlobalVariableAdapter */
        $adapter = $this->adapter('globalVariable');
        //Pre validates the request object
        $adapter->validateObject($object, Request::METHOD_POST);
        $globalVar = $this->getVariableInstance();
        $variable = $this->getGlobalVariable($name, $globalVar, 0, $farmId);
        if (empty($variable)) {
            throw new ApiErrorException(404, ErrorMessage::ERR_OBJECT_NOT_FOUND, "Requested Global Variable does not exist.");
        }
        $entity = $this->makeGlobalVariableEntity($variable);
        $adapter->copyAlterableProperties($object, $entity, ScopeInterface::SCOPE_FARM);
        $this->updateGlobalVariable($globalVar, $variable, $object, $name, ScopeInterface::SCOPE_FARM, 0, $farmId);
        $data = $this->getGlobalVariable($name, $globalVar, 0, $farmId);
        return $this->result($adapter->convertData($data));
    }