public function run() { try { $this->options->parse(); } catch (\Exception $e) { $this->_handleException($e, false); $this->_showLine($this->options->getUsage()); $this->_exit(); } $configFile = $this->options->getConfigFile(); if (!\file_exists($configFile) || !\is_readable($configFile)) { $this->_showError(sprintf("File '%s' cannot be found or not readable", $configFile)); } $config = (require $configFile); if (!is_array($config)) { $this->_showError(sprintf("Invalid config file '%s'", $configFile)); } $this->_showInfo(sprintf("Loaded config file '%s' ...", $configFile)); $perunClientFactory = new PerunClient\ClientFactory(); $perunClient = $perunClientFactory->createClient($config); $managerName = $this->options->getManagerName(); $functionName = $this->options->getFunctionName(); $arguments = $this->options->getArguments(); $this->_showInfo(sprintf("Calling %s->%s (%s)", $managerName, $functionName, http_build_query($arguments, null, ', '))); $startTime = time(); $response = $perunClient->sendRequest($managerName, $functionName, $arguments); $endTime = time(); $this->_showInfo(sprintf("Time: %d second(s)", $endTime - $startTime)); if ($response->isError()) { $this->_showError(sprintf("Perun error [%s]: [%s/%s] %s", $response->getErrorId(), $response->getErrorName(), $response->getErrorType(), $response->getErrorMessage())); } $data = $this->_processResultData($response->getPayload()->getParams(), $this->options->getFilter()); if ($this->options->getOption('entity')) { $entityFactory = new GenericFactory(); $entity = $entityFactory->create($data); print_r($entity); } else { print_r($data); } $this->_showInfo('Result OK'); $this->_exit(0); }
<?php use InoPerunApi\Client\ClientFactory; use InoPerunApi\Manager\GenericManager; include __DIR__ . '/_common.php'; $config = (require __DIR__ . '/_client_config.php'); $clientFactory = new ClientFactory(); $client = $clientFactory->createClient($config); $usersManager = new GenericManager($client); $usersManager->setManagerName('usersManager'); /* $user = $usersManager->callMethod('getRichUserWithAttributes', array( 'user' => 13521 )); */ $user = $usersManager->getRichUserWithAttributes(array('user' => 13521)); _dump($user);