Scalr\Api\Service\User\V1beta0\Controller\Roles::deleteVariableAction PHP Method

deleteVariableAction() public method

Deletes role's global variable
public deleteVariableAction ( integer $roleId, string $name ) : Scalr\Api\DataType\ResultEnvelope
$roleId integer
$name string
return Scalr\Api\DataType\ResultEnvelope
    public function deleteVariableAction($roleId, $name)
    {
        $this->checkScopedPermissions('ROLES', 'MANAGE');
        $this->getRole($roleId, true);
        $fetch = $this->getGlobalVariable($name, $this->getVariableInstance(), $roleId);
        $roleVariable = Entity\GlobalVariable\RoleGlobalVariable::findPk($roleId, $name);
        if (empty($fetch)) {
            throw new ApiErrorException(404, ErrorMessage::ERR_OBJECT_NOT_FOUND, "Requested Global Variable does not exist.");
        }
        if (empty($roleVariable)) {
            throw new ApiErrorException(403, ErrorMessage::ERR_SCOPE_VIOLATION, "You can only delete Global Variables declared in Role scope.");
        }
        $roleVariable->delete();
        return $this->result(null);
    }