istic-openstack/server/core/Identity.php

2594 lines
61 KiB
PHP
Raw Normal View History

<?php
/**
* File containing the identity Class.
*
* @version 1.0 Initialisation of this file
* @since 1.0 Core application's file
*
* @author Eole 'eoledev at outlook . fr'
*
* @todo Complete the functions and finish the descriptions
*/
2016-02-12 12:45:00 +01:00
use OpenStack\Common\Error;
/**
* Identity Class of the back-end application
*
* This class allow the communication between the front-end application and
* the library which allow to send requests to an Openstack instance.
*
*/
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;
/** @var array $actions protected, contains the functions which can be call by the front-end */
protected $actions = array();
/**
* identity constructor
*
* @param App $app the main app object
*
* @throws [Type] [<description>]
*
* @return identity
*/
public function __construct($app){
$this->app = $app;
$this->libClass = $app->getLibClass("Identity");
}
$credentials = array();
/**
* 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
*
* @return void
*/
$credentials["addCredential"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* List the credentials for a given user.
*
* @return void
*/
$credentials["listCredentials"] = function(){
2016-02-12 15:45:25 +01:00
try{
$this->libClass->listCredentials()
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Retrieve a users access/secret pair by the access key.
*
* @param String $credentialId Required credential id for which it retrieve the details
*
* @return void
*/
$credentials["showCredential"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($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...
*
* @return void
*/
$credentials["updateCredential"] = function(){
$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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Delete a users access/secret pair.
*
* @param String $credentialId Required credential id to delete
*
* @return void
*/
$credentials["deleteCredential"] = function(){
$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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}-
$domains = array();
/**
* 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
*
* @return void
*/
$domains["addDomain"] = function(){
$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))
$opt = array('description' => $description, 'enabled' => $enabled, 'name' => $name);
elseif(isset($enabled))
$opt = array('enabled' => $enabled, 'name' => $name);
elseif(isset($description))
$opt = array('description' => $description, 'name' => $name);
else
$opt = array('name' => $name);
try{
$res = $this->libClass->createCredential($opt);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Retrieve the different domain's list.
*
* @return void
*/
$domains["listDomains"] = function(){
try{
$this->libClass->listDomains()
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Retrieve the details of a given domain.
*
* @param String $domainId Required Domain id for which it retrieve the details
*
* @return void
*/
$domains["showDomain"] = function(){
$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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($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
*
* @return void
*/
$domains["updateDomain"] = function(){
$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;
}
try{
$domain = $this->libClass->getDomain($domId);
if(isset($name))
$domain->name = $name;
if(isset($enabled))
$domain->enabled = $enabled;
if(isset($description))
$domain->description = $description;
$domain->update();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Delete the given domain.
*
* @param String $domainId Required Domain id to delete
*
* @return void
*/
$domains["deleteDomain"] = function(){
$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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Retrieve the different roles of a given user in a domain.
*
* @throws [Type] [<description>]
*
* @return void
*/
$domains["listRolesDomainUser"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Grant a role to a given user in a domain.
*
* @throws [Type] [<description>]
*
* @return void
*/
$domains["grantRoleDomainUser"] = function(){
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([
'userId' => $userId,
'roleId' => $roleId,
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Verify that a user has a given role in a domain.
*
* @throws [Type] [<description>]
*
* @return void
*/
$domains["checkRoleDomainUser"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Delete a role for a given user in a domain.
*
* @throws [Type] [<description>]
*
* @return void
*/
$domains["revokeRoleDomainUser"] = function(){
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([
'userId' => $userId,
'roleId' => $roleId,
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Retrieve the roles of a given group in a domain.
*
* @throws [Type] [<description>]
*
* @return void
*/
$domains["listRolesDomainGroup"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Add a role to a given group in a domain.
*
* @throws [Type] [<description>]
*
* @return void
*/
$domains["grantRoleDomainGroup"] = function(){
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([
'groupId' => $groupId,
'roleId' => $roleId,
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Verify that a role is associated with a given group in a domain.
*
* @throws [Type] [<description>]
*
* @return void
*/
$domains["checkRoleDomainGroup"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Delete a role for a given group in a domain.
*
* A *description*, that can span multiple lines, to go _in-depth_ into the details of this element
* and to provide some background information or textual references.
*
* @param string $myArgument With a *description* of this argument, these may also
* span multiple lines.
*
* @throws [Type] [<description>]
*
* @return void
*/
$domains["revokeRoleDomainGroup"] = function(){
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([
'groupId' => $groupId,
'roleId' => $roleId,
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
$endpoints = array();
/**
* Add an endpoint to the Openstack instance
*
* @throws [Type] [<description>]
*
* @return void
*/
$endpoints["addEndpoint"] = function(){
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([
'interface' => \OpenStack\Identity\v3\Enum::INTERFACE_INTERNAL,
'name' => $name,
'region' => $region,
'url' => $url,
'serviceId' => $servId
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Retrieve the endpoint for the given id
*
* @throws [Type] [<description>]
*
* @return void
*/
$endpoints["getEndpoint"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Retrieve the list of the different endpoints
*
* @return void
*/
$endpoints["listEndpoints"] = function(){
2016-02-12 20:03:21 +01:00
try{
$res = $this->libClass->listEndpoints();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Update a given endpoint
*
* @throws [Type] [<description>]
*
* @return void
*/
$endpoints["updateEndpoint"] = function(){
2016-02-12 20:03:21 +01:00
//Not Implemented Yet
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)){
}
//TODO PARAMETERS
try{
$endpoint = $this->libClass->getEndpoint('{endpointId}');
$endpoint->interface = \OpenStack\Identity\v3\Enum::INTERFACE_PUBLIC;
$endpoint->update();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}*/
}
/**
* Delete a given endpoint
*
* @throws [Type] [<description>]
*
* @return void
*/
$endpoints["deleteEndpoint"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
$groups = array();
/**
* Add a group.
*
* @throws [Type] [<description>]
*
* @return void
*/
$groups["addGroup"] = function(){
2016-02-12 20:03:21 +01:00
//Not Implemented Yet
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{
$this->libClass->listCredentials()
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}*/
}
/**
* Retrieve the group's list.
*
* @throws [Type] [<description>]
*
* @return void
*/
$groups["listGroups"] = function(){
2016-02-12 20:03:21 +01:00
//Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
2016-02-12 20:03:21 +01:00
if(!isset($domId) || !isset($groupId)){
}
try{
$this->libClass->listCredentials()
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}*/
}
/**
* Retrieve the details of a given group.
*
* @throws [Type] [<description>]
*
* @return void
*/
$groups["showGroup"] = function(){
2016-02-12 20:03:21 +01:00
//Not Implemented Yet
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{
$this->libClass->listCredentials()
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}*/
}
/**
* Update a given group.
*
* @throws [Type] [<description>]
*
* @return void
*/
$groups["updateGroup"] = function(){
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))
$group->description = 'foo';
if(isset($name))
$group->name = 'bar';
$group->update();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Delete the given group.
*
* @throws [Type] [<description>]
*
* @return void
*/
$groups["deleteGroup"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Retrieve the users of a given group.
*
* @throws [Type] [<description>]
*
* @return void
*/
$groups["listGroupUsers"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Add a user to a group.
*
* @throws [Type] [<description>]
*
* @return void
*/
$groups["addGroupUser"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Remove a user from a given group.
*
* @throws [Type] [<description>]
*
* @return void
*/
$groups["removeGroupUser"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Check if a group contains a given user.
*
* @throws [Type] [<description>]
*
* @return void
*/
$groups["checkGroupUser"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
$policies = array();
/**
* @todo
*
* @throws [Type] [<description>]
*
* @return void
*/
$policies["addPolicies"] = function(){
2016-02-12 20:03:21 +01:00
//Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
2016-02-12 20:03:21 +01:00
if(!isset($domId) || !isset($groupId)){
}
try{
$this->libClass->listCredentials()
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}*/
}
/**
* @todo
*
* @throws [Type] [<description>]
*
* @return void
*/
$policies["listPolicies"] = function(){
2016-02-12 20:03:21 +01:00
//Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
2016-02-12 20:03:21 +01:00
if(!isset($domId) || !isset($groupId)){
}
try{
$this->libClass->listCredentials()
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}*/
}
/**
* @todo
*
* @throws [Type] [<description>]
*
* @return void
*/
$policies["showPolicie"] = function(){
2016-02-12 20:03:21 +01:00
//Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
2016-02-12 20:03:21 +01:00
if(!isset($domId) || !isset($groupId)){
}
try{
$this->libClass->listCredentials()
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}*/
}
/**
* @todo
*
* @throws [Type] [<description>]
*
* @return void
*/
$policies["updatePolicies"] = function(){
2016-02-12 20:03:21 +01:00
//Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
2016-02-12 20:03:21 +01:00
if(!isset($domId) || !isset($groupId)){
}
try{
$this->libClass->listCredentials()
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}*/
}
/**
* @todo
*
* @throws [Type] [<description>]
*
* @return void
*/
$policies["deletePolicies"] = function(){
2016-02-12 20:03:21 +01:00
//Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
2016-02-12 20:03:21 +01:00
if(!isset($domId) || !isset($groupId)){
}
try{
$this->libClass->listCredentials()
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}*/
}
$projects = array();
/**
* Add a project.
*
* @throws [Type] [<description>]
*
* @return void
*/
$projects["addProject"] = function(){
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([
'description' => $description,
'enabled' => true,
'name' => $name
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Retrieve the different projects.
*
* @return void
*/
$projects["listProjects"] = function(){
2016-02-12 20:03:21 +01:00
try{
$projects = $this->libClass->listProjects();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Retrieve the details of a given project.
*
* @throws [Type] [<description>]
*
* @return void
*/
$projects["showProject"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Update a given project.
*
* @throws [Type] [<description>]
*
* @return void
*/
$projects["updateProject"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Delete a given project.
*
* @throws [Type] [<description>]
*
* @return void
*/
$projects["deleteProject"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* List the roles of a given user in a project.
*
* @throws [Type] [<description>]
*
* @return void
*/
$projects["listRolesProjectUser"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Grant a role to an user in a project.
*
* @throws [Type] [<description>]
*
* @return void
*/
$projects["grantRoleProjectUser"] = function(){
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([
'userId' => $userId,
'roleId' => $roleId,
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Check if a given user has a role in a project.
*
* @throws [Type] [<description>]
*
* @return void
*/
$projects["checkRoleProjectUser"] = function(){
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([
'userId' => $userId,
'roleId' => $roleId,
]);
/*if (true === $result) {
}*/
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Delete a role for a given user in a project.
*
* @throws [Type] [<description>]
*
* @return void
*/
$projects["revokeRoleProjectUser"] = function(){
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([
'userId' => $userId,
'roleId' => $roleId,
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* List the roles of a group in a project.
*
* @throws [Type] [<description>]
*
* @return void
*/
$projects["listRolesProjectGroup"] = function(){
2016-02-12 20:03:21 +01:00
$projId = $this->app->getPostParam("projetId");
$groupId = $this->app->getPostParam("groupId");
if(!isset($projId) || !isset($groupId)){
}
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Add a role to a group in a project.
*
* @throws [Type] [<description>]
*
* @return void
*/
$projects["grantRoleProjectGroup"] = function(){
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->grantUserRole([
'userId' => $userId,
'roleId' => $roleId,
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Check if a group has a given role in a project.
*
* @throws [Type] [<description>]
*
* @return void
*/
$projects["checkRoleProjectGroup"] = function(){
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([
'groupId' => $groupId,
'roleId' => $roleId,
]);
/*if (true === $result) {
}*/
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Delete a role for a group in a project.
*
* @throws [Type] [<description>]
*
* @return void
*/
$projects["revokeRoleProjectGroup"] = function(){
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([
'groupId' => $groupId,
'roleId' => $roleId,
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
$roles = array();
/**
* Add a role.
*
* @throws [Type] [<description>]
*
* @return void
*/
$roles["addRole"] = function(){
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([
'name' => $name,
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* List the different roles
*
* @return void
*/
$roles["listRoles"] = function(){
2016-02-12 20:03:21 +01:00
try{
$roles = $this->libClass->listRoles();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* @todo
*
* @return void
*/
$roles["listRoleAssignements"] = function(){
2016-02-12 20:03:21 +01:00
try{
$assignements = $this->libClass->listRoleAssignments();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
$services = array();
/**
* Add a service.
*
* @throws [Type] [<description>]
*
* @return void
*/
$services["addService"] = function(){
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([
'name' => $name,
'type' => $type,
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Retrieve the different services.
*
* @return void
*/
$services["listServices"] = function(){
2016-02-12 20:03:21 +01:00
try{
$services = $this->libClass->listServices();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Retrieve the details for a given service.
*
* @throws [Type] [<description>]
*
* @return void
*/
$services["showService"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Delete a given service.
*
* @throws [Type] [<description>]
*
* @return void
*/
$services["deleteService"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
$tokens = array();
/**
* Generate a new token for a given user id.
*
* @throws [Type] [<description>]
*
* @return void
*/
$tokens["genTokenUserID"] = function(){
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([
'user' => [
'id' => $userId,
'password' => $userPass
]
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Generate a new token for a given user name.
*
* @throws [Type] [<description>]
*
* @return void
*/
$tokens["genTokenUserName"] = function(){
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([
'user' => [
'name' => $username,
'password' => $userPass,
'domain' => [
'id' => $domId
]
]
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Generate a new token from another token ID.
*
* @throws [Type] [<description>]
*
* @return void
*/
$tokens["geneTokenID"] = function(){
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([
'tokenId' => $tokenId,
'scope' => ['project' => ['id' => $projectId]]
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Generate a new token scoped by a project ID.
*
* @throws [Type] [<description>]
*
* @return void
*/
$tokens["genTokenScopedProjectID"] = function(){
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([
'user' => [
'id' => $userId,
'password' => $userPass
],
'scope' => [
'project' => ['id' => $projId]
]
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Generate a new token scoped by a project name.
*
* @throws [Type] [<description>]
*
* @return void
*/
$tokens["genTokenScopedProjectName"] = function(){
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([
'user' => [
'id' => $userId,
'password' => $userPass
],
'scope' => [
'project' => [
'name' => $projName,
'domain' => [
'id' => $domId
]
]
]
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Check if a token is validate.
*
* @throws [Type] [<description>]
*
* @return void
*/
$tokens["validateToken"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Delete a given token.
*
* @throws [Type] [<description>]
*
* @return void
*/
$tokens["revokeToken"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
$users = array();
/**
* Add a new user.
*
* @throws [Type] [<description>]
*
* @return void
*/
$users["addUser"] = function(){
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-02-12 20:03:21 +01:00
}
try{
$user = $this->libClass->createUser([
'defaultProjectId' => $projId,
'description' => $desc,
'domainId' => $domId,
'email' => $email,
'enabled' => true,
'name' => $name,
'password' => $pass
]);
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Retrieve the different users.
*
* @return void
*/
$users["listUsers"] = function(){
2016-02-12 20:03:21 +01:00
try{
$users = $this->libClass->listUsers();
//TODO parse answer
}catch(BadResponseError $e){
$this->app->getErrorInstance->BadResponseHandler($e);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Retrieve the details of a given user.
*
* @throws [Type] [<description>]
*
* @return void
*/
$users["showUser"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Update a given user.
*
* @throws [Type] [<description>]
*
* @return void
*/
$users["updateUser"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Delete a given user.
*
* @throws [Type] [<description>]
*
* @return void
*/
$users["deleteUser"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Retrieve the groups which contains a given user.
*
* @throws [Type] [<description>]
*
* @return void
*/
$users["listUserGroups"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
/**
* Retrieve the projects which contains a given user.
*
* @throws [Type] [<description>]
*
* @return void
*/
$users["listUserProjects"] = function(){
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);
}catch(UserInputError $e){
$this->app->getErrorInstance->UserInputHandler($e);
}catch(BaseError $e){
$this->app->getErrorInstance->BaseErrorHandler($e);
}catch(NotImplementedError $e){
$this->app->getErrorInstance->NotImplementedHandler($e);
}
}
$actions["Credentials"] = $credentials;
$actions["Domains"] = $domains;
$actions["Endpoints"] = $endpoints;
$actions["Groups"] = $groups;
$actions["Policies"] = $policies;
$actions["Projects"] = $projects;
$actions["Roles"] = $roles;
$actions["Services"] = $services;
$actions["Tokens"] = $tokens;
$actions["Users"] = $users;
}