protected function writeService(KalturaServiceReflector $serviceReflector) { $serviceName = $serviceReflector->getServiceName(); $serviceId = $serviceReflector->getServiceId(); $serviceClass = $serviceReflector->getServiceClass(); $actions = $serviceReflector->getActions(); foreach ($actions as $action => $actionName) { $actionInfo = $serviceReflector->getActionInfo($action); if ($actionInfo->deprecated || $actionInfo->serverOnly) { continue; } if (strpos($actionInfo->clientgenerator, "ignore") !== false) { continue; } $outputTypeReflector = $serviceReflector->getActionOutputType($action); $actionParams = $serviceReflector->getActionParams($action); $this->writeServiceAction($serviceId, $serviceName, $actionInfo->action, $actionParams, $outputTypeReflector); } }
<?php require_once "../../bootstrap.php"; KalturaLog::setContext("TESTME"); $service = $_GET["service"]; $serviceReflector = new KalturaServiceReflector($service); $actionsArray = $serviceReflector->getActions(); $actionNames = array_keys($actionsArray); sort($actionNames); $actions = array(); foreach ($actionNames as $actionName) { $actionInfo = $serviceReflector->getActionInfo($actionName); if (!$actionInfo->deprecated) { $actions[] = $actionInfo->action; } } echo json_encode($actions);
public function setIncludeOrExcludeList($include, $exclude) { // load full list of actions and services $fullList = array(); $serviceMap = KalturaServicesMap::getMap(); $services = array_keys($serviceMap); foreach ($services as $service) { $serviceReflector = new KalturaServiceReflector($service); $actions = $serviceReflector->getActions(); foreach ($actions as &$action) { // we need only the keys $action = true; } $fullList[$service] = $actions; } $includeList = array(); if ($include !== null) { $tempList = explode(",", str_replace(" ", "", $include)); foreach ($tempList as $item) { $service = null; $action = null; $item = strtolower($item); if (strpos($item, ".") !== false) { list($service, $action) = explode(".", $item); } if (!key_exists($service, $includeList)) { $includeList[$service] = array(); } if ($action == "*") { if (!array_key_exists($service, $fullList)) { throw new Exception("Service [{$service}] not found"); } $includeList[$service] = $fullList[$service]; } else { $includeList[$service][$action] = true; } } } else { if ($exclude !== null) { $includeList = $fullList; $tempList = explode(",", str_replace(" ", "", $exclude)); foreach ($tempList as $item) { $service = null; $action = null; $item = strtolower($item); if (strpos($item, ".") !== false) { list($service, $action) = explode(".", $item); } if ($action == "*") { // KalturaLog::debug("Excluding service [$service]"); unset($includeList[$service]); } else { // KalturaLog::debug("Excluding action [$service.$action]"); unset($includeList[$service][$action]); } } } else { $includeList = $fullList; } } $this->setIncludeList($includeList); }
private function testSingleService($service, $testedClient, $permissions, $alwaysAllowedActions) { $serviceReflector = new KalturaServiceReflector($service); $actions = array_keys($serviceReflector->getActions()); $serviceName = $serviceReflector->getServiceName(); foreach ($actions as $action) { // Params $actionParams = $serviceReflector->getActionParams($action); $params = array(); foreach ($actionParams as $actionParam) { $actionName = $actionParam->getName(); $typeName = $actionParam->getType(); if ($typeName == "KalturaPermissionItem") { $params[] = new KalturaApiActionPermissionItem(); continue; } if ($actionParam->isComplexType()) { if ($actionParam->isArray()) { $params[] = array(); } else { $type = $actionParam->getTypeReflector(); if ($type != null) { if (!$type->isAbstract()) { $params[] = $type->getInstance(); } else { //TODO: handle abstract classes $params[] = new KalturaApiActionPermissionItem(); } } else { $params[] = null; } } } else { $params[] = 0; } } if ($action == "list") { $action .= "Action"; } try { call_user_func_array(array($testedClient->{$serviceName}, $action), $params); //TODO: Handle non exception cases $this->compareServiceAction($permissions, $alwaysAllowedActions, $serviceName, $action); } catch (Exception $ex) { //Check if the service / action is found in the user permissions $this->compareServiceAction($permissions, $alwaysAllowedActions, $serviceName, $action, $ex); } } }
<?php try { $serviceReflector = new KalturaServiceReflector($service); } catch (Exception $ex) { die('Service "' . $service . '" not found'); } $actions = $serviceReflector->getActions(); try { $actionParams = $serviceReflector->getActionParams($action); } catch (Exception $ex) { die('Action "' . $action . '" does not exist for service "' . $service . '"'); } $actionInfo = $serviceReflector->getActionInfo($action); ?> <h2>Kaltura API</h2> <table class="action"> <tr> <th colspan="3" class="service_action_title"><?php echo $service; ?> :<?php echo $action; ?> </th> </tr> <tr> <td colspan="3" class="title">Description:</td> </tr> <tr> <td class="description" colspan="3"><?php