Identity Some functions Implementations, App error class binding on authenticate, ErrorManagement Implementation Beginning
This commit is contained in:
parent
6960c81a1f
commit
6890283bcf
3 changed files with 211 additions and 33 deletions
|
@ -64,15 +64,14 @@ class App{
|
|||
|
||||
$this->setOutput("token", $this->tokenClass->getBackup());
|
||||
}catch(BadResponseError $e){
|
||||
var_dump($e);
|
||||
}catch(UserInputError $e){
|
||||
var_dump($e);
|
||||
}catch(BaseError $e){
|
||||
var_dump($e);
|
||||
exit();
|
||||
}catch(NotImplementedError $e){
|
||||
var_dump($e);
|
||||
}
|
||||
$this->errorClass->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
$this->errorClass->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
$this->errorClass->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
$this->errorClass->NotImplementedHandler($e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -22,11 +22,11 @@ Class errorManagement{
|
|||
}
|
||||
|
||||
public function BadResponseHandler($error){
|
||||
|
||||
$this->app->setOutput("Error", "Erreur Interne, Merci de contacter un administrateur!");
|
||||
}
|
||||
|
||||
public function NotImplementedHandler($error){
|
||||
|
||||
$this->app->setOutput("Error", "Erreur Interne, Merci de contacter un administrateur!");
|
||||
}
|
||||
|
||||
public function UserInputHandler($error){
|
||||
|
|
|
@ -53,10 +53,10 @@ class identity implements Core{
|
|||
* 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 credentials information with this structure for ec2: "{\"access\":\"181920\",\"secret\":\"secretKey\"}"
|
||||
* @param String $projectId project's UUID
|
||||
* @param String $type Type of credential : ec2, cert...
|
||||
* @param String $userId Id of the user which own the credential
|
||||
* @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
|
||||
*/
|
||||
|
@ -69,6 +69,7 @@ class identity implements Core{
|
|||
|
||||
if(!isset($blob) || !isset($projectId) || !isset($type) || !isset($userId)){
|
||||
$this->app->setOutput("Error", "Parameters Incorrect");
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
|
@ -76,6 +77,8 @@ class identity implements Core{
|
|||
$opt = array('blob' => $blob, 'projectId' => $projectId, 'type' => $type, 'userId' => $userId);
|
||||
$res = $this->libClass->createCredential($opt);
|
||||
|
||||
//TODO parse answer
|
||||
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
|
@ -115,13 +118,17 @@ class identity implements Core{
|
|||
/**
|
||||
* Retrieve a user’s access/secret pair by the access key.
|
||||
*
|
||||
* @param String $credentialId credential id for which it retrieve the details
|
||||
* @param String $credentialId Required credential id for which it retrieve the details
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
$credentials["showCredential"] = function(){
|
||||
$credentId = $this->app->getPostParam("credentialId");
|
||||
|
||||
if(!isset($credentId)){
|
||||
$this->app->setOutput("Error", "Parameters Incorrect");
|
||||
}
|
||||
|
||||
try{
|
||||
|
||||
$cred = $this->libClass->getCredential($credentId);
|
||||
|
@ -144,93 +151,265 @@ class identity implements Core{
|
|||
/**
|
||||
* Update a user’s access/secret pair.
|
||||
*
|
||||
* @throws [Type] [<description>]
|
||||
* @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(){
|
||||
$credential = $identity->getCredential('credentialId');
|
||||
|
||||
$credential->type = 'foo';
|
||||
$credential->blob = 'bar';
|
||||
|
||||
$credential->update();
|
||||
|
||||
$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);
|
||||
|
||||
$credential->type = $type;
|
||||
$credential->blob = $blob;
|
||||
|
||||
$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 user’s access/secret pair.
|
||||
*
|
||||
* @throws [Type] [<description>]
|
||||
* @param String $credentialId Required credential id to delete
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
$credentials["deleteCredential"] = function(){
|
||||
$credential = $identity->getCredential('credentialId');
|
||||
$credential->delete();
|
||||
|
||||
}
|
||||
$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.
|
||||
*
|
||||
* @throws [Type] [<description>]
|
||||
* @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.
|
||||
*
|
||||
* @throws [Type] [<description>]
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
* @throws [Type] [<description>]
|
||||
* @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.
|
||||
*
|
||||
* @throws [Type] [<description>]
|
||||
* @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.
|
||||
*
|
||||
* @throws [Type] [<description>]
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue