Refactoring of comments beginning

This commit is contained in:
EoleDev 2016-04-26 20:42:31 +02:00
parent 477dc82182
commit 5263cf00a2
13 changed files with 1535 additions and 1744 deletions

View file

@ -1,11 +1,21 @@
<?php
date_default_timezone_set('Europe/Paris');
/**
* File containing the code for the API door.
*
* @version 1.0 Initialisation of this file
* @since 1.0 Core application's file
*
* @author Eole 'eoledev at outlook . fr'
*
*/
$config = Array();
date_default_timezone_set('Europe/Paris');
$config["modules_enabled"] = "";
$config["urlAuth"] = "http://148.60.11.31:5000/v3";
$config["tokenTime"] = 60 //minute = 60
$config = Array();
$config["modules_enabled"] = "";
$config["urlAuth"] = "http://148.60.11.31:5000/v3";
$config["tokenTime"] = 60; //minute = 60
?>

View file

@ -1,21 +1,53 @@
<?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'
*
*/
//Library token management override
include_once("core/LibOverride/genTokenOptions.php");
include_once("core/ErrorManagement.php");
//Library loading
use OpenCloud\Common\Error\BadResponseError;
use OpenCloud\Common\Error\BaseError;
use OpenCloud\Common\Error\NotImplementedError;
use OpenCloud\Common\Error\UserInputError;
/**
* App 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 App{
/** @var Openstack $openstack protected, contains the main library object */
protected $openstack;
/** @var Array $postParams protected, contains the post parameters */
protected $postParams;
/** @var genTokenOptions $tokenClass protected, contains the class object for the authentication override of the library */
protected $tokenClass;
/** @var String $tokenPost protected, contains the token given in parameter */
protected $tokenPost;
/** @var errorManagement $errorClass protected, contains the errorManagement object */
protected $errorClass;
/** @var Array $output protected, contains the result for the API call */
protected $output;
/**
* App constructor
*
* @param Array $args Args for the OpenStack Library
*
* @return App object
*/
public function __construct($args){
$this->tokenPost = NULL;
@ -27,6 +59,13 @@ class App{
}
/**
* Set the class var $tokenPost and load the token
* into the genTokenOptions Class
*
* @param String $token token to be set
*
*/
public function setToken($token){
$this->tokenPost = $token;
@ -34,10 +73,22 @@ class App{
}
/**
* Check the expiration of the token
*
* @return Boolean if the token is not expired
*/
public function checkToken(){
return $this->tokenClass->checkToken();
}
/**
* Get the service Class given the name in parameter
*
* @param String $service Name of the service
*
* @return Core object
*/
public function getLibClass($service){
switch($service){
@ -70,6 +121,11 @@ class App{
}
/**
* Generate the token for the different services in OpenStack
*
* @return NULL
*/
public function authenticate(){
try{
@ -91,6 +147,11 @@ class App{
}
/**
* Revoke the openstack services' token
*
* @return NULL
*/
public function deauthenticate(){
try{
@ -113,6 +174,13 @@ class App{
}
/**
* Retrieve a post parameter given its name
*
* @param String $name Expected post parameter's name
*
* @return Object Post value
*/
public function getPostParam($name){
if(isset($this->postParams[$name])){
@ -123,28 +191,52 @@ class App{
}
/**
* Set a post parameter for automating task
*
* @param String $param Name for the Post entry
* @param Object $value Value for the Post entry
*
* @return NULL
*/
public function setPostParam($param, $value){
$this->postParams[$param] = $value;
}
/**
* Set a new output message
*
* @param String $key Array key for the message
* @param Array $out Message's value
*
* @return NULL
*/
public function setOutput($key, $out){
$this->output[$key] = $out;
}
/**
* Retrieve the errorManagement instance Object
*
* @return errorManagement object
*/
public function getErrorInstance(){
return $this->errorClass;
}
/**
* Output the messages to be send to the client
*
* @return NULl
*/
public function show(){
echo json_encode($this->output);
//error_log(var_dump(json_encode($this->output), true), 0);
}
}

View file

@ -5,9 +5,8 @@
* @version 1.0 Initialisation of this file
* @since 1.0 Core application's file
*
* @author Evan Pisani 'yogg at epsina . com' et bhupi
* @author Evan Pisani 'yogg at epsina . com', bhupi
*
* @todo Complete the functions with errors detection and finish the descriptions
*/
include("Image.php");
@ -44,7 +43,7 @@ class automating{
*
* @param String $action name of another function of this class
*
* @return void
* @return NULL
*/
public function action($action){
$this->{$action.""}();
@ -58,7 +57,7 @@ class automating{
* @param String $serverName name ofthe new server
* @param String $flavor kind of server
*
* @return void
* @return NULL
*/
private function createPublicServer()
{

View file

@ -21,7 +21,7 @@ class compute
*
* @param String $action name of another function of this class
*
* @return void
* @return NULL
*/
public function action($action){
@ -300,7 +300,7 @@ class compute
/**
* update a server
* @return void
* @return NULL
*/
public function updateServer()
{
@ -346,7 +346,7 @@ class compute
}
/**
* Delete a server
* @return void
* @return NULL
*/
public function deleteServer()
{
@ -380,7 +380,7 @@ class compute
}
/**
* Change the password of a server
* @return void
* @return NULL
*/
public function changePassword()
{
@ -415,7 +415,7 @@ class compute
}
/**
* Reboot a server
* @return void
* @return NULL
*/
public function reboot()
{
@ -449,7 +449,7 @@ class compute
}
/**
* Rebuild a server
* @return void
* @return NULL
*/
public function rebuild()
{
@ -496,7 +496,7 @@ class compute
/**
* Resize a server
* A call to this method has to be followed by either confirmResize or revertResize
* @return void
* @return NULL
*/
public function resize()
{
@ -530,7 +530,7 @@ class compute
}
/**
* Confirm resize operation on a server
* @return void
* @return NULL
*/
public function confirmResize()
{
@ -564,7 +564,7 @@ class compute
}
/**
* Revert resize operation on a server
* @return void
* @return NULL
*/
public function revertResize()
{
@ -598,7 +598,7 @@ class compute
}
/**
* List private and public addresses of a server
* @return void
* @return NULL
*/
public function listAddresses(array $options = [])

View file

@ -1,5 +1,13 @@
<?php
/**
* File containing Core Interface
*
* @version 1.0 Initialisation of this file
* @since 1.0 Core application's file
*
* @author Eole 'eoledev at outlook . fr'
*
*/
interface Core{
public function action($action);

View file

@ -22,9 +22,9 @@ Class errorManagement{
/**
* ErrorManagemement constructor
*
* @param App $app the main app object
* @param App $args the main app object
*
* @return ErrorManagement
* @return ErrorManagement Object
*/
public function __construct($args){
@ -35,9 +35,9 @@ Class errorManagement{
/**
* Put an error message corresponding to a base error in the output
*
* @param $error the error triggered
* @param Exception $error the exception triggered
*
* @return String BaseError message
* @return NULL
*/
public function BaseErrorHandler($error){
$this->app->setOutput("Error", "BaseError");
@ -46,9 +46,9 @@ Class errorManagement{
/**
* Put an error message corresponding to a bad response in function of the status code in the output
*
* @param $error the error triggered
* @param Exception $error the exception triggered
*
* @return String Error message
* @return NULL
*/
public function BadResponseHandler($error){
$statusCode = $error->getResponse()->getStatusCode();
@ -86,9 +86,9 @@ Class errorManagement{
/**
* Put an error message corresponding to a not implemented yet error in the output
*
* @param $error the error triggered
* @param Exception $error the exception triggered
*
* @return String internal error message
* @return NULL
*/
public function NotImplementedHandler($error){
$this->app->setOutput("Error", "Internal error (not implemented yet), please contact an administrator");
@ -97,9 +97,9 @@ Class errorManagement{
/**
* Put an error message corresponding to a user input error in the output
*
* @param $error the error triggered
* @param Exception $error the exception triggered
*
* @return String User input error message
* @return NULL
*/
public function UserInputHandler($error){
$this->app->setOutput("Error", "UserInputError");
@ -108,9 +108,9 @@ Class errorManagement{
/**
* Put an error message corresponding to an other error in the output
*
* @param $error the error triggered
* @param Exception $error the exception triggered
*
* @return String error message
* @return NULL
*/
public function OtherException($error){
$this->app->setOutput("Error", $error->getMessage());

View file

@ -7,15 +7,13 @@
*
* @author Eole 'eoledev at outlook . fr'
*
* @todo Complete the functions and finish the descriptions
*/
use OpenCloud\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.
* This class implements the management for the identity request
*
*/
class identity implements Core{
@ -31,8 +29,6 @@ class identity implements Core{
*
* @param App $app the main app object
*
* @throws [Type] [<description>]
*
* @return identity
*/
public function __construct($app){
@ -47,7 +43,7 @@ class identity implements Core{
*
* @param String $action name of another function of this class
*
* @return void
* @return NULL
*/
public function action($action){
@ -65,7 +61,7 @@ class identity implements Core{
* @param String $type Required Type of credential : ec2, cert...
* @param String $userId Required Id of the user which own the credential
*
* @return void
* @return NULL
*/
private function addCredential(){
@ -103,7 +99,7 @@ class identity implements Core{
/**
* List the credentials for a given user.
*
* @return void
* @return NULL
*/
private function listCredentials(){
try{
@ -131,7 +127,7 @@ class identity implements Core{
*
* @param String $credentialId Required credential id for which it retrieve the details
*
* @return void
* @return NULL
*/
private function showCredential(){
$credentId = $this->app->getPostParam("credentialId");
@ -168,7 +164,7 @@ class identity implements Core{
* @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
* @return NULL
*/
private function updateCredential(){
@ -210,7 +206,7 @@ class identity implements Core{
*
* @param String $credentialId Required credential id to delete
*
* @return void
* @return NULL
*/
private function deleteCredential(){
@ -248,7 +244,7 @@ class identity implements Core{
* @param String $enabled Optional Domain enabled or not : value true or false
* @param String $name Required Domain Name
*
* @return void
* @return NULL
*/
private function addDomain(){
@ -293,7 +289,7 @@ class identity implements Core{
/**
* Retrieve the different domain's list.
*
* @return void
* @return NULL
*/
private function listDomains(){
@ -322,7 +318,7 @@ class identity implements Core{
*
* @param String $domainId Required Domain id for which it retrieve the details
*
* @return void
* @return NULL
*/
private function showDomain(){
@ -360,7 +356,7 @@ class identity implements Core{
* @param String $enabled Optional Domain enabled or not : value true or false
* @param String $name Required Domain Name
*
* @return void
* @return NULL
*/
private function updateDomain(){
@ -408,7 +404,7 @@ class identity implements Core{
*
* @param String $domainId Required Domain id to delete
*
* @return void
* @return NULL
*/
private function deleteDomain(){
@ -441,9 +437,7 @@ class identity implements Core{
/**
* Retrieve the different roles of a given user in a domain.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function listRolesDomainUser(){
@ -478,9 +472,7 @@ class identity implements Core{
/**
* Grant a role to a given user in a domain.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function grantRoleDomainUser(){
$domId = $this->app->getPostParam("domainId");
@ -518,9 +510,7 @@ class identity implements Core{
/**
* Verify that a user has a given role in a domain.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function checkRoleDomainUser(){
$domId = $this->app->getPostParam("domainId");
@ -559,9 +549,7 @@ class identity implements Core{
/**
* Delete a role for a given user in a domain.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function revokeRoleDomainUser(){
$domId = $this->app->getPostParam("domainId");
@ -599,9 +587,7 @@ class identity implements Core{
/**
* Retrieve the roles of a given group in a domain.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function listRolesDomainGroup(){
$domId = $this->app->getPostParam("domainId");
@ -636,9 +622,7 @@ class identity implements Core{
/**
* Add a role to a given group in a domain.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function grantRoleDomainGroup(){
$domId = $this->app->getPostParam("domainId");
@ -676,9 +660,7 @@ class identity implements Core{
/**
* Verify that a role is associated with a given group in a domain.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function checkRoleDomainGroup(){
$domId = $this->app->getPostParam("domainId");
@ -717,15 +699,7 @@ class identity implements Core{
/**
* 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
* @return NULL
*/
private function revokeRoleDomainGroup(){
$domId = $this->app->getPostParam("domainId");
@ -764,9 +738,7 @@ class identity implements Core{
/**
* Add an endpoint to the Openstack instance
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function addEndpoint(){
$servId = $this->app->getPostParam("serviceId");
@ -806,9 +778,7 @@ class identity implements Core{
/**
* Retrieve the endpoint for the given id
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function getEndpoint(){
@ -840,7 +810,7 @@ class identity implements Core{
/**
* Retrieve the list of the different endpoints
*
* @return void
* @return NULL
*/
private function listEndpoints(){
@ -866,50 +836,16 @@ class identity implements Core{
/**
* Update a given endpoint
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function updateEndpoint(){
//Not Implemented Yet
/*$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
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);
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}*/
}
/**
* Delete a given endpoint
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function deleteEndpoint(){
$endId = $this->app->getPostParam("endpointId");
@ -941,115 +877,34 @@ class identity implements Core{
/**
* Add a group.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function addGroup(){
//Not Implemented Yet
/*$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
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);
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}*/
}
/**
* Retrieve the group's list.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function listGroups(){
//Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
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);
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}*/
}
/**
* Retrieve the details of a given group.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function showGroup(){
//Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
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);
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}*/
}
/**
* Update a given group.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function updateGroup(){
//Todo Argument Optional
@ -1090,9 +945,7 @@ class identity implements Core{
/**
* Delete the given group.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function deleteGroup(){
@ -1126,9 +979,7 @@ class identity implements Core{
/**
* Retrieve the users of a given group.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function listGroupUsers(){
@ -1162,9 +1013,7 @@ class identity implements Core{
/**
* Add a user to a group.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function addGroupUser(){
@ -1199,9 +1048,7 @@ class identity implements Core{
/**
* Remove a user from a given group.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function removeGroupUser(){
@ -1236,9 +1083,7 @@ class identity implements Core{
/**
* Check if a group contains a given user.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function checkGroupUser(){
@ -1273,185 +1118,53 @@ class identity implements Core{
/**
* @todo
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function addPolicies(){
//Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
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);
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}*/
}
/**
* @todo
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function listPolicies(){
//Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
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);
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}*/
}
/**
* @todo
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function showPolicie(){
//Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
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);
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}*/
}
/**
* @todo
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function updatePolicies(){
//Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
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);
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}*/
}
/**
* @todo
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function deletePolicies(){
//Not Implemented Yet
/*
$domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId");
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);
}catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}*/
}
/**
* Add a project.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function addProject(){
//Todo Parameters Optional
@ -1488,7 +1201,7 @@ class identity implements Core{
/**
* Retrieve the different projects.
*
* @return void
* @return NULL
*/
private function listProjects(){
@ -1514,9 +1227,7 @@ class identity implements Core{
/**
* Retrieve the details of a given project.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function showProject(){
@ -1549,9 +1260,7 @@ class identity implements Core{
/**
* Update a given project.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function updateProject(){
//Todo Parameters Optionnal
@ -1591,9 +1300,7 @@ class identity implements Core{
/**
* Delete a given project.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function deleteProject(){
$projId = $this->app->getPostParam("projId");
@ -1626,9 +1333,7 @@ class identity implements Core{
/**
* List the roles of a given user in a project.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function listRolesProjectUser(){
@ -1665,9 +1370,7 @@ class identity implements Core{
/**
* Grant a role to an user in a project.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function grantRoleProjectUser(){
@ -1706,9 +1409,7 @@ class identity implements Core{
/**
* Check if a given user has a role in a project.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function checkRoleProjectUser(){
$projId = $this->app->getPostParam("projetId");
@ -1749,9 +1450,7 @@ class identity implements Core{
/**
* Delete a role for a given user in a project.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function revokeRoleProjectUser(){
@ -1790,9 +1489,7 @@ class identity implements Core{
/**
* List the roles of a group in a project.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function listRolesProjectGroup(){
@ -1828,9 +1525,7 @@ class identity implements Core{
/**
* Add a role to a group in a project.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function grantRoleProjectGroup(){
@ -1869,9 +1564,7 @@ class identity implements Core{
/**
* Check if a group has a given role in a project.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function checkRoleProjectGroup(){
@ -1912,9 +1605,7 @@ class identity implements Core{
/**
* Delete a role for a group in a project.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function revokeRoleProjectGroup(){
@ -1953,9 +1644,7 @@ class identity implements Core{
/**
* Add a role.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function addRole(){
@ -1989,7 +1678,7 @@ class identity implements Core{
/**
* List the different roles
*
* @return void
* @return NULL
*/
private function listRoles(){
@ -2013,9 +1702,9 @@ class identity implements Core{
}
/**
* @todo
* List the different assignments for a given role
*
* @return void
* @return NULL
*/
private function listRoleAssignements(){
@ -2041,9 +1730,7 @@ class identity implements Core{
/**
* Add a service.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function addService(){
$name = $this->app->getPostParam("name");
@ -2078,7 +1765,7 @@ class identity implements Core{
/**
* Retrieve the different services.
*
* @return void
* @return NULL
*/
private function listServices(){
@ -2104,9 +1791,7 @@ class identity implements Core{
/**
* Retrieve the details for a given service.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function showService(){
$servId = $this->app->getPostParam("serviceId");
@ -2137,9 +1822,7 @@ class identity implements Core{
/**
* Delete a given service.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function deleteService(){
@ -2173,9 +1856,7 @@ class identity implements Core{
/**
* Generate a new token for a given user id.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function genTokenUserID(){
@ -2213,9 +1894,7 @@ class identity implements Core{
/**
* Generate a new token for a given user name.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function genTokenUserName(){
$username = $this->app->getPostParam("username");
@ -2257,9 +1936,7 @@ class identity implements Core{
/**
* Generate a new token from another token ID.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function genTokenID(){
@ -2295,9 +1972,7 @@ class identity implements Core{
/**
* Generate a new token scoped by a project ID.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function genTokenScopedProjectID(){
@ -2339,9 +2014,7 @@ class identity implements Core{
/**
* Generate a new token scoped by a project name.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function genTokenScopedProjectName(){
@ -2389,9 +2062,7 @@ class identity implements Core{
/**
* Check if a token is validate.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function validateToken(){
@ -2427,9 +2098,7 @@ class identity implements Core{
/**
* Delete a given token.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function revokeToken(){
@ -2461,9 +2130,7 @@ class identity implements Core{
/**
* Add a new user.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function addUser(){
//Todo Optionnal Parameter
@ -2508,7 +2175,7 @@ class identity implements Core{
/**
* Retrieve the different users.
*
* @return void
* @return NULL
*/
private function listUsers(){
@ -2534,9 +2201,7 @@ class identity implements Core{
/**
* Retrieve the details of a given user.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function showUser(){
@ -2569,9 +2234,7 @@ class identity implements Core{
/**
* Update a given user.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function updateUser(){
@ -2610,9 +2273,7 @@ class identity implements Core{
/**
* Delete a given user.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function deleteUser(){
@ -2645,9 +2306,7 @@ class identity implements Core{
/**
* Retrieve the groups which contains a given user.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function listUserGroups(){
@ -2681,9 +2340,7 @@ class identity implements Core{
/**
* Retrieve the projects which contains a given user.
*
* @throws [Type] [<description>]
*
* @return void
* @return NULL
*/
private function listUserProjects(){

View file

@ -51,7 +51,7 @@ class image implements Core{
*
* @param String $action name of another function of this class
*
* @return void
* @return NULL
*/
public function action($action){
$this->{$action.""}();
@ -272,7 +272,7 @@ class image implements Core{
*
* @param String $id Identifier of the image
*
* @return void
* @return NULL
*/
private function deleteImage(){
$id = $this->app->getPostParam("id");
@ -306,7 +306,7 @@ class image implements Core{
*
* @param String $id Identifier of the image
*
* @return void
* @return NULL
*/
private function reactivateImage(){
$id = $this->app->getPostParam("id");
@ -343,7 +343,7 @@ class image implements Core{
*
* @param String $id Identifier of the image
*
* @return void
* @return NULL
*/
private function desactivateImage(){
$id = $this->app->getPostParam("id");
@ -380,7 +380,7 @@ class image implements Core{
* @param String $id Identifier of the image
* @param String $file_name Path of the image
*
* @return void
* @return NULL
*/
private function uploadImage(){
$id = $this->app->getPostParam("id");
@ -591,7 +591,7 @@ class image implements Core{
* @param String $image_id Identifier of the image
* @param String $member_id Identifier of the member
*
* @return void
* @return NULL
*/
private function removeMemberImage(){
$image_id = $this->app->getPostParam("image_id");
@ -637,7 +637,7 @@ class image implements Core{
* @param String $member_id Identifier of the member
* @param String $status New status for the member
*
* @return void
* @return NULL
**/
private function updateMemberImage(){
$image_id = $this->app->getPostParam("image_id");

View file

@ -22,9 +22,9 @@ use OpenCloud\Common\Error\UserInputError;
*/
class network{
/** @var App $app protected, contains the main app object */
/** @var App $app protected, contains the main app object */
protected $app;
/** @var OpenStack\Network $libClass protected, contains the library Network object */
/** @var OpenStack\Network $libClass protected, contains the library Network object */
protected $libClass;
@ -49,7 +49,7 @@ class network{
*
* @param String $action name of another function of this class
*
* @return void
* @return NULL
*/
public function action($action){
@ -65,7 +65,7 @@ class network{
* @param String shared Specifies whether the network resource can be accessed by any tenant
* @param String tenantId Owner of network. Only admin users can specify a tenant ID other than their own
*
* @return void
* @return NULL
*/
private function create_network()
{
@ -136,7 +136,7 @@ class network{
*
*
*
* @return void
* @return NULL
*/
private function create_subnet()
@ -498,7 +498,7 @@ class network{
* @param String tenantId Owner of network. Only admin users can specify a tenant ID other than their own
*
*
* @return void
* @return NULL
**/
private function updateNetwork()
@ -561,7 +561,7 @@ class network{
* @param String allocationPools Subranges of the CIDR available for dynamic allocation to ports
*
*
* @return void
* @return NULL
**/
private function updateSubnet()
@ -617,7 +617,7 @@ class network{
* @param String networkId ID if network which we want to delete
*
*
* @return void
* @return NULL
**/
private function deleteNetwork()
{
@ -651,7 +651,7 @@ class network{
* @param String subnetId ID if network which we want to delete
*
*
* @return void
* @return NULL
**/
private function deleteSubnet()
{
@ -692,7 +692,7 @@ class network{
* @param String securityGroups Specifies the IDs of any security groups associated with this port
* @param String tenantId Owner of the port. Only admin users can specify a tenant ID other than their own.
*
* @return void
* @return NULL
*/
private function createPort()
@ -876,7 +876,7 @@ class network{
* @param String securityGroups Specifies the IDs of any security groups associated with this port
* @param String tenantId Owner of the port. Only admin users can specify a tenant ID other than their own.
*
* @return void
* @return NULL
*/
private function updatePort()
{
@ -953,7 +953,7 @@ class network{
* Delete a port given
*
* @param String portId id of port which we wante to delete
* @return void
* @return NULL
*/
private function deletePort()
{
@ -988,7 +988,7 @@ class network{
* @param String name A human-readable name for the security group. This name might not be unique
* @param String description Description of the security group
*
* @return void
* @return NULL
*/
private function createSecurityGroup()
@ -1040,7 +1040,7 @@ class network{
*@param String remoteGroupId The remote group ID to be associated with this security group rule. You can specify either remoteGroupId or remoteGroupPrefix
*@param String remoteIpPrefix The remote IP prefix to be associated with this security group rule. You can specify either remoteGroupId or remoteGroupPrefix
*
* @return void
* @return NULL
*/
private function createSecurityGroupRule()
{
@ -1239,7 +1239,7 @@ class network{
/**
* Delete a specific Security Groupe given
* @param securityGroupeId ID of security Groupe which we want to get
* @return void
* @return NULL
*/
private function deleteSecurityGroupe()
{

View file

@ -51,7 +51,7 @@ class networkLayer3 {
*
* @param String $action name of another function of this class
*
* @return void
* @return NULL
*/
public function action($action){
$this->{$action.""}();
@ -175,7 +175,7 @@ class networkLayer3 {
*
* @param id the id of the floatingip to update
*
* @return void
* @return NULL
*/
private function updateFloatingIp(){
$id = $this->app->getPostParam("id");
@ -224,7 +224,7 @@ class networkLayer3 {
*
* @param string floatingip_id the floating-ip id to delete
*
* @return void
* @return NULL
*/
private function deleteFloatingIp(){
$id = $this->app->getPostParam("id");
@ -273,7 +273,7 @@ class networkLayer3 {
*
* @param string floatingip_id the floating-ip id to retrieve
*
* @return void
* @return NULL
*/
private function retrieveFloatingIp(){
$id = $this->app->getPostParam("id");
@ -437,7 +437,7 @@ class networkLayer3 {
*
* @param string router the router to delete
*
* @return void
* @return NULL
*/
private function deleteRouter(){
$id = $this->app->getPostParam("id");
@ -485,7 +485,7 @@ class networkLayer3 {
*
* @param id the id of the floatingip to update
*
* @return void
* @return NULL
*/
private function updateRouter(){
$id = $this->app->getPostParam("id");

View file

@ -1,28 +1,45 @@
<?php
require "vendor/autoload.php";
include_once("config.inc.php");
include_once("init.php");
/**
* File containing the code for the API door.
*
* @version 1.0 Initialisation of this file
* @since 1.0 Core application's file
*
* @author Eole 'eoledev at outlook . fr'
*
*/
if(isset($_POST["task"]) && isset($_POST["action"])){
//loading dependencies
require "vendor/autoload.php";
//Include general config file
include_once("config.inc.php");
//Include API initialisation
include_once("init.php");
if(isset($_POST["task"]) && isset($_POST["action"])){
$task = $_POST["task"];
$action = $_POST["action"];
}else if(isset($_POST["task"]) && $_POST["task"] == "Authenticate" || $_POST["task"] == "Deauthenticate"){
}else if(isset($_POST["task"]) && $_POST["task"] == "Authenticate" || $_POST["task"] == "Deauthenticate"){
$task = $_POST["task"];
}else{
//Gestion Erreur
}
}else{
$App->setOutput("Error", "Invalid Request!");
$App->show();
exit();
}
if($task == "Authenticate"){
//Authentification and deauthentification request
if($task == "Authenticate"){
$App->authenticate();
$App->show();
}else if($task == "Deauthenticate"){
}else if($task == "Deauthenticate"){
$App->deauthenticate();
$App->show();
}else if($App->checkToken()){
}else if($App->checkToken()){
//Task switcher and task's file loader
switch($task)
{
case "identity":
@ -61,10 +78,11 @@
break;
}
}else{
}else{
//Request without authentication
$App->setOutput("Error", "Token Invalide");
$App->show();
}
}

View file

@ -1,30 +1,36 @@
<?php
include_once("core/App.php");
/**
* File containing the initialisation of the API.
*
* @version 1.0 Initialisation of this file
* @since 1.0 Core application's file
*
* @author Eole 'eoledev at outlook . fr'
*
*/
$user = "";
$password = "";
$project = "";
include_once("core/App.php");
$user = "";
$password = "";
$project = "";
//traitement requete, recuperation data
if(isset($_POST["token"])){
//token processing
if(isset($_POST["token"])){
$token = $_POST["token"];
}else if(isset($_POST["user"]) && isset($_POST["password"]) && isset($_POST["project"]) ){
}else if(isset($_POST["user"]) && isset($_POST["password"]) && isset($_POST["project"]) ){
$user = $_POST["user"];
$password = $_POST["password"];
$project = $_POST["project"];
} /*else { // Test Backend
$user = "admin";
$password = "ae5or6cn";
$project = "admin";
}
}*/
$Args = Array(
//Library args
$Args = Array(
"user" => Array(
"name" => $user,
"password" => $password,
@ -39,10 +45,11 @@
)
),
"authUrl" => $config["urlAuth"]
);
);
$App = new App($Args);
//Init core Api
$App = new App($Args);
if(isset($token))
if(isset($token))
$App->setToken($token);
?>