'; echo''; echo''; echo'Gorgias Cloud API Test'; echo''; echo''; $this->executeGorgias(); echo''; echo''; } private function executeGorgias() { $opApiInstance = new OperationsControllerApi(); $opApiInstance->getConfig()->setUsername("some_user"); $opApiInstance->getConfig()->setPassword("some_password"); $opApiInstance->getConfig()->setHost("http://aiasvm1.amcl.tuc.gr:8085"); echo "

Gorgias Cloud API Test

"; //get the user's projects and print them on the terminal, some_project must be listed $projects = $opApiInstance->getUserProjectsUsingGET(); echo "

My projects:

"; echo "
    "; foreach ($projects as $project) { echo "
  1. ".$project."
  2. "; } echo "
"; //example of using the prolog API $apiInstance = new ExecuteGorgiasQueryControllerApi(); $apiInstance->getConfig()->setUsername("some_user"); $apiInstance->getConfig()->setPassword("some_password"); $apiInstance->getConfig()->setHost("http://aiasvm1.amcl.tuc.gr:8085"); $gorgias_query = new GorgiasQuery();// GorgiasQuery | gorgiasQuery //example of using the prolog API to consult your file $gorgias_query->setGorgiasFiles(array("someProject/somePolicy.pl")); //example of using the prolog API to assert a fact $factsList=array(); $fact="request(some_agent,some_tool)"; $factsList[]=$fact; $gorgias_query->setFacts($factsList); //example of using the prolog API to prove a policy option $myQuery = "challenge(Agent, Resource)"; $gorgias_query->setQuery($myQuery); $gorgias_query->setResultSize(1); $gorgiasQueryResult = $apiInstance->executeQueryUsingPOST($gorgias_query); if($gorgiasQueryResult->getHasError()){ echo "
".$gorgiasQueryResult->getErrorMsg(); }else if($gorgiasQueryResult->getHasResult()){ $queryResult=$gorgiasQueryResult->getResult(); foreach ($queryResult as $result) { $explanation=$result->getExplanation(); $explanationRulesHeadWithoutVariables= $result->getExplanationRulesHeadWithoutVariables(); echo '

ExplanationStr:'.$result->getExplanationStr().'

' ; echo '

'.$result->getHumanExplanation().'

'; $variablesMap=$result->getVariables(); echo '

Variables List

'; echo ""; } } } } $test=new Test(); ?>