/** * Deletes role's global variable * * @param int $roleId * @param string $name * @return \Scalr\Api\DataType\ResultEnvelope * @throws ApiErrorException * @throws \Scalr\Exception\ModelException */ 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); }