istic-openstack/server/core/Identity.php

2379 lines
56 KiB
PHP
Raw Normal View History

<?php
/**
* File containing the identity Class.
*
2016-04-27 14:22:59 +02:00
*/
/**
* Import the Error of the Library
*/
2016-03-09 15:21:46 +01:00
use OpenCloud\Common\Error;
2016-04-26 20:42:31 +02:00
2016-05-05 19:16:10 +02:00
require_once("CoreInterface.php");
/**
* Identity Class of the back-end application
*
2016-04-26 20:42:31 +02:00
* This class implements the management for the identity request
*
2016-04-27 14:22:59 +02:00
* @version 1.0 Initialisation of this file
* @since 1.0 Core application's file
*
* @author Eole 'eoledev at outlook . fr'
*
*/
class identity implements Core{
/** @var App $app protected, contains the main app object */
protected $app;
/** @var OpenStack\Identity $libClass protected, contains the library Identity object */
protected $libClass;
/**
* identity constructor
*
* @param App $app the main app object
*
2016-04-27 14:22:59 +02:00
* @return identity Object
*/
public function __construct($app){
$this->app = $app;
$this->libClass = $app->getLibClass("Identity");
}
/**
* Execute an action
*
* @param String $action name of another function of this class
*
2016-04-27 14:22:59 +02:00
* @return void
*/
public function action($action){
2016-04-26 20:42:31 +02:00
$this->{$action.""}();
}
/**
* Add a credential for the given user/project.
*
* Create a secret/access pair for use with ec2 style auth.
* This operation will generates a new set of credentials that map the user/project pair.
*
* @param JsonString $blob Required credentials information with this structure for ec2: "{\"access\":\"181920\",\"secret\":\"secretKey\"}"
* @param String $projectId Required project's UUID
* @param String $type Required Type of credential : ec2, cert...
* @param String $userId Required Id of the user which own the credential
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function addCredential(){
2016-02-12 12:45:00 +01:00
$blob = $this->app->getPostParam("blob");
$projectId = $this->app->getPostParam("projectId");
$type = $this->app->getPostParam("type");
$userId = $this->app->getPostParam("userId");
if(!isset($blob) || !isset($projectId) || !isset($type) || !isset($userId)){
$this->app->setOutput("Error", "Parameters Incorrect");
return;
2016-02-12 12:45:00 +01:00
}
try{
$opt = array('blob' => $blob, 'projectId' => $projectId, 'type' => $type, 'userId' => $userId);
$res = $this->libClass->createCredential($opt);
//TODO parse answer
2016-02-12 15:45:25 +01:00
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* List the credentials for a given user.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function listCredentials(){
2016-02-12 15:45:25 +01:00
try{
$this->libClass->listCredentials()
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Retrieve a users access/secret pair by the access key.
*
* @param String $credentialId Required credential id for which it retrieve the details
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function showCredential(){
2016-02-12 15:45:25 +01:00
$credentId = $this->app->getPostParam("credentialId");
if(!isset($credentId)){
$this->app->setOutput("Error", "Parameters Incorrect");
}
2016-02-12 15:45:25 +01:00
try{
$cred = $this->libClass->getCredential($credentId);
$cred->retrieve();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Update a users access/secret pair.
*
* @param String $credentialId Required credential id to update
* @param JsonString $blob Required credentials information with this structure for ec2: "{\"access\":\"181920\",\"secret\":\"secretKey\"}"
* @param String $type Required Type of credential : ec2, cert...
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function updateCredential(){
$credentId = $this->app->getPostParam("credentialId");
$blob = $this->app->getPostParam("blob");
$type = $this->app->getPostParam("type");
if(!isset($blob) || !isset($credentId) || !isset($type)){
$this->app->setOutput("Error", "Parameters Incorrect");
}
try{
$credential = $this->libClass->getCredential($credentId);
2016-02-12 12:45:00 +01:00
$credential->type = $type;
$credential->blob = $blob;
2016-02-12 12:45:00 +01:00
$credential->update();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Delete a users access/secret pair.
*
* @param String $credentialId Required credential id to delete
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function deleteCredential(){
$credentId = $this->app->getPostParam("credentialId");
if(!isset($credentId)){
$this->app->setOutput("Error", "Parameters Incorrect");
}
try{
$credential = $this->libClass->getCredential($credentId);
$credential->delete();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}-
/**
* Add a domain to an OpenStack instance.
*
* @param String $desc Optional Domain Description
* @param String $enabled Optional Domain enabled or not : value true or false
* @param String $name Required Domain Name
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function addDomain(){
$description = $this->app->getPostParam("desc");
$enabled = $this->app->getPostParam("enabled");
$name = $this->app->getPostParam("name");
if(!isset($name)){
$this->app->setOutput("Error", "Parameters Incorrect");
return;
}
if(isset($enabled) && isset($description))
2016-04-26 20:42:31 +02:00
$opt = array('description' => $description, 'enabled' => $enabled, 'name' => $name);
elseif(isset($enabled))
2016-04-26 20:42:31 +02:00
$opt = array('enabled' => $enabled, 'name' => $name);
elseif(isset($description))
2016-04-26 20:42:31 +02:00
$opt = array('description' => $description, 'name' => $name);
else
2016-04-26 20:42:31 +02:00
$opt = array('name' => $name);
try{
$res = $this->libClass->createCredential($opt);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Retrieve the different domain's list.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function listDomains(){
try{
$this->libClass->listDomains()
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Retrieve the details of a given domain.
*
* @param String $domainId Required Domain id for which it retrieve the details
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function showDomain(){
$domId = $this->app->getPostParam("domainId");
if(!isset($domId)){
$this->app->setOutput("Error", "Parameters Incorrect");
}
try{
$domain = $this->libClass->getDomain($domId);
$domain->retrieve();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Update the given domain.
*
* @param String $domainId Required domain id to update
* @param String $desc Optional Domain Description
* @param String $enabled Optional Domain enabled or not : value true or false
* @param String $name Required Domain Name
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function updateDomain(){
$domId = $this->app->getPostParam("domainId");
$description = $this->app->getPostParam("desc");
$enabled = $this->app->getPostParam("enabled");
$name = $this->app->getPostParam("name");
if(!isset($domId)){
$this->app->setOutput("Error", "Parameters Incorrect");
return;
}
2016-04-26 20:42:31 +02:00
try{
$domain = $this->libClass->getDomain($domId);
if(isset($name))
2016-04-26 20:42:31 +02:00
$domain->name = $name;
if(isset($enabled))
2016-04-26 20:42:31 +02:00
$domain->enabled = $enabled;
if(isset($description))
2016-04-26 20:42:31 +02:00
$domain->description = $description;
$domain->update();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Delete the given domain.
*
* @param String $domainId Required Domain id to delete
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function deleteDomain(){
$domId = $this->app->getPostParam("domainId");
if(!isset($domId)){
$this->app->setOutput("Error", "Parameters Incorrect");
}
try{
$domain = $this->libClass->getDomain($domId);
$domain->delete();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Retrieve the different roles of a given user in a domain.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function listRolesDomainUser(){
2016-02-12 20:03:21 +01:00
$domId = $this->app->getPostParam("domainId");
$userId = $this->app->getPostParam("userId");
if(!isset($domId) || !isset($userId)){
}
2016-02-12 20:03:21 +01:00
try{
$domain = $this->libClass->getDomain($domId);
$domain->listUserRoles(['userId' => $userId]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Grant a role to a given user in a domain.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function grantRoleDomainUser(){
2016-02-12 20:03:21 +01:00
$domId = $this->app->getPostParam("domainId");
$roleId = $this->app->getPostParam("roleId");
$userId = $this->app->getPostParam("userId");
2016-02-12 20:03:21 +01:00
if(!isset($domId) || !isset($roleId) || !isset($userId)){
}
2016-02-12 20:03:21 +01:00
try{
$domain = $this->libClass->getDomain($domId);
$domain->grantUserRole([
2016-04-26 20:42:31 +02:00
'userId' => $userId,
'roleId' => $roleId,
2016-02-12 20:03:21 +01:00
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Verify that a user has a given role in a domain.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function checkRoleDomainUser(){
2016-02-12 20:03:21 +01:00
$domId = $this->app->getPostParam("domainId");
$roleId = $this->app->getPostParam("roleId");
$userId = $this->app->getPostParam("userId");
2016-02-12 20:03:21 +01:00
if(!isset($domId) || !isset($roleId) || !isset($userId)){
}
try{
$domain = $this->libClass->getDomain($domId);
$result = $domain->checkUserRole(['userId' => $userId, 'roleId' => $roleId]);
/*if (true === $result) {
// It exists!
}*/
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Delete a role for a given user in a domain.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function revokeRoleDomainUser(){
2016-02-12 20:03:21 +01:00
$domId = $this->app->getPostParam("domainId");
$roleId = $this->app->getPostParam("roleId");
$userId = $this->app->getPostParam("userId");
2016-02-12 20:03:21 +01:00
if(!isset($domId) || !isset($roleId) || !isset($userId)){
}
2016-02-12 20:03:21 +01:00
try{
$domain = $this->libClass->getDomain($domId);
$domain->revokeUserRole([
2016-04-26 20:42:31 +02:00
'userId' => $userId,
'roleId' => $roleId,
2016-02-12 20:03:21 +01:00
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Retrieve the roles of a given group in a domain.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function listRolesDomainGroup(){
2016-02-12 20:03:21 +01:00
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
2016-02-12 20:03:21 +01:00
if(!isset($domId) || !isset($groupId)){
}
try{
$domain = $this->libClass->getDomain($domId);
$domain->listGroupRoles(['groupId' => $groupId]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Add a role to a given group in a domain.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function grantRoleDomainGroup(){
2016-02-12 20:03:21 +01:00
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
$roleId = $this->app->getPostParam("roleId");
2016-02-12 20:03:21 +01:00
if(!isset($domId) || !isset($groupId) || !isset($roleId)){
}
try{
$domain = $this->libClass->getDomain($domId);
$domain->grantGroupRole([
2016-04-26 20:42:31 +02:00
'groupId' => $groupId,
'roleId' => $roleId,
2016-02-12 20:03:21 +01:00
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Verify that a role is associated with a given group in a domain.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function checkRoleDomainGroup(){
2016-02-12 20:03:21 +01:00
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
$roleId = $this->app->getPostParam("roleId");
2016-02-12 20:03:21 +01:00
if(!isset($domId) || !isset($groupId) || !isset($roleId)){
}
try{
$domain = $this->libClass->getDomain($domId);
$result = $domain->checkGroupRole(['groupId' => $groupId, 'roleId' => $roleId]);
/*if (true === $result) {
// It exists!
}*/
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Delete a role for a given group in a domain.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function revokeRoleDomainGroup(){
2016-02-12 20:03:21 +01:00
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
$roleId = $this->app->getPostParam("roleId");
2016-02-12 20:03:21 +01:00
if(!isset($domId) || !isset($groupId) || !isset($roleId)){
}
2016-02-12 20:03:21 +01:00
try{
$domain = $this->libClass->getDomain($roleId);
$domain->revokeGroupRole([
2016-04-26 20:42:31 +02:00
'groupId' => $groupId,
'roleId' => $roleId,
2016-02-12 20:03:21 +01:00
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Add an endpoint to the Openstack instance
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function addEndpoint(){
2016-02-12 20:03:21 +01:00
$servId = $this->app->getPostParam("serviceId");
$name = $this->app->getPostParam("name");
$region = $this->app->getPostParam("region");
$url = $this->app->getPostParam("url");
2016-02-12 20:03:21 +01:00
if(!isset($servId) || !isset($name) || !isset($region) || !isset($url)){
}
2016-02-12 20:03:21 +01:00
try{
$endpoint = $this->libClass->createEndpoint([
2016-04-26 20:42:31 +02:00
'interface' => \OpenStack\Identity\v3\Enum::INTERFACE_INTERNAL,
'name' => $name,
'region' => $region,
'url' => $url,
'serviceId' => $servId
2016-02-12 20:03:21 +01:00
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Retrieve the endpoint for the given id
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function getEndpoint(){
2016-02-12 20:03:21 +01:00
$endId = $this->app->getPostParam("endpointId");
if(!isset($endId)){
}
2016-02-12 20:03:21 +01:00
try{
$endpoint = $this->libClass->getEndpoint($endId);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Retrieve the list of the different endpoints
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function listEndpoints(){
2016-04-26 20:42:31 +02:00
2016-02-12 20:03:21 +01:00
try{
$res = $this->libClass->listEndpoints();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Update a given endpoint
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function updateEndpoint(){
2016-02-12 20:03:21 +01:00
//Not Implemented Yet
}
/**
* Delete a given endpoint
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function deleteEndpoint(){
2016-02-12 20:03:21 +01:00
$endId = $this->app->getPostParam("endpointId");
2016-02-12 20:03:21 +01:00
if(!isset($endId)){
}
2016-02-12 20:03:21 +01:00
try{
$endpoint = $this->libClass->getEndpoint($endId);
$endpoint->delete();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Add a group.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function addGroup(){
2016-02-12 20:03:21 +01:00
//Not Implemented Yet
}
/**
* Retrieve the group's list.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function listGroups(){
2016-02-12 20:03:21 +01:00
//Not Implemented Yet
}
/**
* Retrieve the details of a given group.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function showGroup(){
2016-02-12 20:03:21 +01:00
//Not Implemented Yet
}
/**
* Update a given group.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function updateGroup(){
2016-02-12 20:03:21 +01:00
//Todo Argument Optional
$groupId = $this->app->getPostParam("groupId");
$description = $this->app->getPostParam("description");
$name = $this->app->getPostParam("name");
2016-02-12 20:03:21 +01:00
if(!isset($groupId)){
}
2016-02-12 20:03:21 +01:00
try{
$group = $this->libClass->getGroup($groupId);
if(isset($description))
2016-04-26 20:42:31 +02:00
$group->description = 'foo';
2016-02-12 20:03:21 +01:00
if(isset($name))
2016-04-26 20:42:31 +02:00
$group->name = 'bar';
2016-02-12 20:03:21 +01:00
$group->update();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Delete the given group.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function deleteGroup(){
2016-02-12 20:03:21 +01:00
$groupId = $this->app->getPostParam("groupId");
if(!isset($groupId)){
}
2016-02-12 20:03:21 +01:00
try{
$group = $this->libClass->getGroup($groupId);
$group->delete();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Retrieve the users of a given group.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function listGroupUsers(){
2016-02-12 20:03:21 +01:00
$groupId = $this->app->getPostParam("groupId");
2016-02-12 20:03:21 +01:00
if(!isset($groupId)){
}
try{
$group = $this->libClass->getGroup($groupId);
$users = $group->listUsers();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Add a user to a group.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function addGroupUser(){
2016-02-12 20:03:21 +01:00
$userId = $this->app->getPostParam("userId");
$groupId = $this->app->getPostParam("groupId");
2016-02-12 20:03:21 +01:00
if(!isset($userId) || !isset($groupId)){
}
try{
$group = $this->libClass->getGroup($groupId);
$group->addUser(['userId' => $userId]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Remove a user from a given group.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function removeGroupUser(){
2016-02-12 20:03:21 +01:00
$userId = $this->app->getPostParam("userId");
$groupId = $this->app->getPostParam("groupId");
if(!isset($userId) || !isset($groupId)){
}
2016-02-12 20:03:21 +01:00
try{
$group = $this->libClass->getGroup($groupId);
$group->removeUser(['userId' => $userId]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Check if a group contains a given user.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function checkGroupUser(){
2016-02-12 20:03:21 +01:00
$userId = $this->app->getPostParam("userId");
$groupId = $this->app->getPostParam("groupId");
if(!isset($userId) || !isset($groupId)){
}
2016-02-12 20:03:21 +01:00
try{
$group = $this->libClass->getGroup($groupId);
$result = $group->checkMembership(['userId' => $userId]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* @todo
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function addPolicies(){
2016-02-12 20:03:21 +01:00
//Not Implemented Yet
}
/**
* @todo
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function listPolicies(){
2016-02-12 20:03:21 +01:00
//Not Implemented Yet
}
/**
* @todo
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function showPolicie(){
2016-02-12 20:03:21 +01:00
//Not Implemented Yet
}
/**
* @todo
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function updatePolicies(){
2016-02-12 20:03:21 +01:00
//Not Implemented Yet
}
/**
* @todo
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function deletePolicies(){
2016-02-12 20:03:21 +01:00
//Not Implemented Yet
}
/**
* Add a project.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function addProject(){
2016-02-12 20:03:21 +01:00
//Todo Parameters Optional
$description = $this->app->getPostParam("description");
$name = $this->app->getPostParam("name");
2016-02-12 20:03:21 +01:00
if(!isset($name) || !isset($description)){
}
2016-02-12 20:03:21 +01:00
try{
$project = $this->libClass->createProject([
2016-04-26 20:42:31 +02:00
'description' => $description,
'enabled' => true,
'name' => $name
2016-02-12 20:03:21 +01:00
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Retrieve the different projects.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function listProjects(){
2016-02-12 20:03:21 +01:00
try{
$projects = $this->libClass->listProjects();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Retrieve the details of a given project.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function showProject(){
2016-02-12 20:03:21 +01:00
$projId = $this->app->getPostParam("projetId");
2016-02-12 20:03:21 +01:00
if(!isset($projId)){
}
try{
$project = $this->libClass->getProject($projId);
$project->retrieve();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Update a given project.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function updateProject(){
2016-02-12 20:03:21 +01:00
//Todo Parameters Optionnal
$description = $this->app->getPostParam("description");
$name = $this->app->getPostParam("name");
$projId = $this->app->getPostParam("projetId");
2016-02-12 20:03:21 +01:00
if(!isset($projId) || !isset($name) || !isset($description)){
}
2016-02-12 20:03:21 +01:00
try{
$project = $this->libClass->getProject($projId);
$project->enabled = false;
$project->description = $description;
$project->name = $name;
$project->update();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Delete a given project.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function deleteProject(){
2016-02-12 20:03:21 +01:00
$projId = $this->app->getPostParam("projId");
2016-02-12 20:03:21 +01:00
if(!isset($projId)){
}
try{
$project = $this->libClass->getProject($projId);
$project->delete();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* List the roles of a given user in a project.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function listRolesProjectUser(){
2016-02-12 20:03:21 +01:00
$projId = $this->app->getPostParam("projetId");
$userId = $this->app->getPostParam("userId");
2016-02-12 20:03:21 +01:00
if(!isset($projId) || !isset($userId)){
}
try{
$project = $this->libClass->getProject($projId);
$project->listUserRoles(['userId' => $userId]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Grant a role to an user in a project.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function grantRoleProjectUser(){
2016-02-12 20:03:21 +01:00
$projId = $this->app->getPostParam("projId");
$userId = $this->app->getPostParam("userId");
$roleId = $this->app->getPostParam("roleId");
2016-02-12 20:03:21 +01:00
if(!isset($projId) || !isset($userId) || !isset($roleId)){
}
try{
$project = $this->libClass->getProject($projId);
$project->grantUserRole([
2016-04-26 20:42:31 +02:00
'userId' => $userId,
'roleId' => $roleId,
2016-02-12 20:03:21 +01:00
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Check if a given user has a role in a project.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function checkRoleProjectUser(){
2016-02-12 20:03:21 +01:00
$projId = $this->app->getPostParam("projetId");
$userId = $this->app->getPostParam("userId");
$roleId = $this->app->getPostParam("roleId");
2016-02-12 20:03:21 +01:00
if(!isset($projId) || !isset($userId) || !isset($roleId)){
}
2016-02-12 20:03:21 +01:00
try{
$project = $this->libClass->getProject($projId);
$result = $project->checkUserRole([
2016-04-26 20:42:31 +02:00
'userId' => $userId,
'roleId' => $roleId,
2016-02-12 20:03:21 +01:00
]);
/*if (true === $result) {
}*/
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Delete a role for a given user in a project.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function revokeRoleProjectUser(){
2016-02-12 20:03:21 +01:00
$projId = $this->app->getPostParam("projetId");
$userId = $this->app->getPostParam("userId");
$roleId = $this->app->getPostParam("roleId");
if(!isset($projId) || !isset($userId) || !isset($roleId)){
}
2016-02-12 20:03:21 +01:00
try{
$project = $this->libClass->getProject($projId);
$project->revokeUserRole([
2016-04-26 20:42:31 +02:00
'userId' => $userId,
'roleId' => $roleId,
2016-02-12 20:03:21 +01:00
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* List the roles of a group in a project.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function listRolesProjectGroup(){
2016-02-12 20:03:21 +01:00
$projId = $this->app->getPostParam("projetId");
$groupId = $this->app->getPostParam("groupId");
if(!isset($projId) || !isset($groupId)){
}
2016-04-26 20:42:31 +02:00
2016-02-12 20:03:21 +01:00
try{
$project = $this->libClass->getProject($projId);
$project->listGroupRoles(['groupId' => $groupId]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Add a role to a group in a project.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function grantRoleProjectGroup(){
2016-02-12 20:03:21 +01:00
$projId = $this->app->getPostParam("projetId");
$userId = $this->app->getPostParam("userId");
$roleId = $this->app->getPostParam("roleId");
if(!isset($projId) || !isset($userId) || !isset($roleId)){
}
2016-04-26 20:42:31 +02:00
2016-02-12 20:03:21 +01:00
try{
$project = $this->libClass->getProject($projId);
$project->grantUserRole([
2016-04-26 20:42:31 +02:00
'userId' => $userId,
'roleId' => $roleId,
2016-02-12 20:03:21 +01:00
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Check if a group has a given role in a project.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function checkRoleProjectGroup(){
2016-02-12 20:03:21 +01:00
$projId = $this->app->getPostParam("projetId");
$userId = $this->app->getPostParam("userId");
$roleId = $this->app->getPostParam("roleId");
2016-02-12 20:03:21 +01:00
if(!isset($projId) || !isset($userId) || !isset($roleId)){
}
try{
$project = $this->libClass->getProject($projId);
$result = $project->checkGroupRole([
2016-04-26 20:42:31 +02:00
'groupId' => $groupId,
'roleId' => $roleId,
2016-02-12 20:03:21 +01:00
]);
/*if (true === $result) {
}*/
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Delete a role for a group in a project.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function revokeRoleProjectGroup(){
2016-02-12 20:03:21 +01:00
$projId = $this->app->getPostParam("projetId");
$userId = $this->app->getPostParam("userId");
$roleId = $this->app->getPostParam("roleId");
if(!isset($projId) || !isset($userId) || !isset($roleId)){
}
2016-02-12 20:03:21 +01:00
try{
$project = $this->libClass->getProject($projId);
$project->revokeGroupRole([
2016-04-26 20:42:31 +02:00
'groupId' => $groupId,
'roleId' => $roleId,
2016-02-12 20:03:21 +01:00
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Add a role.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function addRole(){
2016-02-12 20:03:21 +01:00
$name = $this->app->getPostParam("name");
2016-02-12 20:03:21 +01:00
if(!isset($name)){
}
try{
$role = $this->libClass->createRole([
2016-04-26 20:42:31 +02:00
'name' => $name,
2016-02-12 20:03:21 +01:00
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* List the different roles
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function listRoles(){
2016-02-12 20:03:21 +01:00
try{
$roles = $this->libClass->listRoles();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
2016-04-26 20:42:31 +02:00
* List the different assignments for a given role
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function listRoleAssignements(){
2016-02-12 20:03:21 +01:00
try{
$assignements = $this->libClass->listRoleAssignments();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Add a service.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function addService(){
2016-02-12 20:03:21 +01:00
$name = $this->app->getPostParam("name");
$type = $this->app->getPostParam("type");
2016-02-12 20:03:21 +01:00
if(!isset($name) || !isset($type)){
}
2016-02-12 20:03:21 +01:00
try{
$service = $this->libClass->createService([
2016-04-26 20:42:31 +02:00
'name' => $name,
'type' => $type,
2016-02-12 20:03:21 +01:00
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Retrieve the different services.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function listServices(){
2016-02-12 20:03:21 +01:00
try{
$services = $this->libClass->listServices();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Retrieve the details for a given service.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function showService(){
2016-02-12 20:03:21 +01:00
$servId = $this->app->getPostParam("serviceId");
2016-02-12 20:03:21 +01:00
if(!isset($servId)){
}
2016-02-12 20:03:21 +01:00
try{
$service = $this->libClass->getService($servId);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Delete a given service.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function deleteService(){
2016-02-12 20:03:21 +01:00
$servId = $this->app->getPostParam("serviceId");
$groupId = $this->app->getPostParam("groupId");
2016-02-12 20:03:21 +01:00
if(!isset($servId) || !isset($groupId)){
}
try{
$service = $this->libClass->getService($servId);
$service->delete();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Generate a new token for a given user id.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function genTokenUserID(){
2016-02-12 20:03:21 +01:00
$userId = $this->app->getPostParam("userId");
$userPass = $this->app->getPostParam("userPassword");
if(!isset($userId) || !isset($userPass)){
}
2016-02-12 20:03:21 +01:00
try{
$token = $this->libClass->generateToken([
2016-04-26 20:42:31 +02:00
'user' => [
'id' => $userId,
'password' => $userPass
]
2016-02-12 20:03:21 +01:00
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Generate a new token for a given user name.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function genTokenUserName(){
2016-02-12 20:03:21 +01:00
$username = $this->app->getPostParam("username");
$userPass = $this->app->getPostParam("userPassword");
$domId = $this->app->getPostParam("domainId");
2016-02-12 20:03:21 +01:00
if(!isset($userId) || !isset($userPass) || !isset($domId)){
}
2016-02-12 20:03:21 +01:00
try{
$token = $this->libClass->generateToken([
2016-04-26 20:42:31 +02:00
'user' => [
'name' => $username,
'password' => $userPass,
'domain' => [
'id' => $domId
]
]
2016-02-12 20:03:21 +01:00
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Generate a new token from another token ID.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function genTokenID(){
2016-02-12 20:03:21 +01:00
$tokenId = $this->app->getPostParam("tokenId");
$projectId = $this->app->getPostParam("projectId");
if(!isset($tokenId) || !isset($projectId)){
}
2016-02-12 20:03:21 +01:00
try{
$token = $this->libClass->generateToken([
2016-04-26 20:42:31 +02:00
'tokenId' => $tokenId,
'scope' => ['project' => ['id' => $projectId]]
2016-02-12 20:03:21 +01:00
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Generate a new token scoped by a project ID.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function genTokenScopedProjectID(){
2016-02-12 20:03:21 +01:00
$userId = $this->app->getPostParam("userId");
$userPass = $this->app->getPostParam("userPass");
$projId = $this->app->getPostParam("projetId");
if(!isset($userId) || !isset($projId) || !isset($userPass)){
}
2016-02-12 20:03:21 +01:00
try{
$token = $this->libClass->generateToken([
2016-04-26 20:42:31 +02:00
'user' => [
'id' => $userId,
'password' => $userPass
],
'scope' => [
'project' => ['id' => $projId]
]
2016-02-12 20:03:21 +01:00
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Generate a new token scoped by a project name.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function genTokenScopedProjectName(){
2016-02-12 20:03:21 +01:00
$userId = $this->app->getPostParam("userId");
$userPass = $this->app->getPostParam("userPass");
$projName = $this->app->getPostParam("projetName");
$domId = $this->app->getPostParam("domId");
2016-02-12 20:03:21 +01:00
if(!isset($userId) || !isset($projName) || !isset($userPass) || !isset($domId)){
}
try{
$token = $this->libClass->generateToken([
2016-04-26 20:42:31 +02:00
'user' => [
'id' => $userId,
'password' => $userPass
],
'scope' => [
'project' => [
'name' => $projName,
'domain' => [
'id' => $domId
]
]
]
2016-02-12 20:03:21 +01:00
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Check if a token is validate.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function validateToken(){
2016-02-12 20:03:21 +01:00
$tokenId = $this->app->getPostParam("tokenId");
2016-02-12 20:03:21 +01:00
if(!isset($tokenId)){
}
try{
$result = $this->libClass->validateToken($tokenId);
/*if (true === $result) {
// It's valid!
}*/
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Delete a given token.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function revokeToken(){
2016-02-12 20:03:21 +01:00
$tokenId = $this->app->getPostParam("tokenId");
if(!isset($tokenId)){
}
2016-02-12 20:03:21 +01:00
try{
$this->libClass->revokeToken($tokenId);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Add a new user.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function addUser(){
2016-02-12 20:03:21 +01:00
//Todo Optionnal Parameter
$projId = $this->app->getPostParam("projId");
$desc = $this->app->getPostParam("description");
$email = $this->app->getPostParam("email");
$name = $this->app->getPostParam("name");
$pass = $this->app->getPostParam("pass");
$domId = $this->app->getPostParam("domId");
2016-02-12 20:03:21 +01:00
if(!isset($domId) || !isset($groupId)){
2016-04-26 20:42:31 +02:00
2016-02-12 20:03:21 +01:00
}
try{
$user = $this->libClass->createUser([
2016-04-26 20:42:31 +02:00
'defaultProjectId' => $projId,
'description' => $desc,
'domainId' => $domId,
'email' => $email,
'enabled' => true,
'name' => $name,
'password' => $pass
2016-02-12 20:03:21 +01:00
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Retrieve the different users.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function listUsers(){
2016-02-12 20:03:21 +01:00
try{
$users = $this->libClass->listUsers();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Retrieve the details of a given user.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function showUser(){
2016-02-12 20:03:21 +01:00
$userId = $this->app->getPostParam("userId");
if(!isset($userId)){
}
2016-02-12 20:03:21 +01:00
try{
$user = $this->libClass->getUser($userId);
$user->retrieve();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Update a given user.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function updateUser(){
2016-02-12 20:03:21 +01:00
$userId = $this->app->getPostParam("userId");
$desc = $this->app->getPostParam("description");
$name = $this->app->getPostParam("name");
if(!isset($userId) || !isset($desc) || !isset($name)){
}
2016-02-12 20:03:21 +01:00
try{
$user = $this->libClass->getUser($userId);
$user->description = $desc;
$user->name = $name;
$user->update();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Delete a given user.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function deleteUser(){
2016-02-12 20:03:21 +01:00
$userId = $this->app->getPostParam("userId");
if(!isset($userId)){
}
2016-02-12 20:03:21 +01:00
try{
$user = $this->libClass->getUser($userId);
$user->delete();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Retrieve the groups which contains a given user.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function listUserGroups(){
2016-02-12 20:03:21 +01:00
$userId = $this->app->getPostParam("userId");
2016-02-12 20:03:21 +01:00
if(!isset($userId)){
}
try{
$user = $this->libClass->getUser($userId);
$groups = $user->listGroups();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
/**
* Retrieve the projects which contains a given user.
*
2016-04-27 14:22:59 +02:00
* @return void
*/
private function listUserProjects(){
2016-02-12 20:03:21 +01:00
$userId = $this->app->getPostParam("userId");
if(!isset($userId)){
}
2016-02-12 20:03:21 +01:00
try{
$user = $this->libClass->getUser($userId);
$projects = $user->listProjects();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
2016-04-26 20:42:31 +02:00
}catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
2016-04-26 20:42:31 +02:00
}catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
2016-04-26 20:42:31 +02:00
}catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
2016-04-26 20:42:31 +02:00
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
}
}