Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit bad7f54

Browse files
committed
ENH: refs #448. Add web api info methods to report enables modules and methods
1 parent ad19919 commit bad7f54

File tree

1 file changed

+37
-5
lines changed

1 file changed

+37
-5
lines changed

modules/api/controllers/components/ApiComponent.php

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,54 @@ private function _getUser($args)
5858

5959
/**
6060
* Get the server version
61-
* @return Server version
61+
* @return Server version in the form <major>.<minor>.<patch>
6262
*/
6363
public function version($args)
6464
{
65-
$data['version'] = Zend_Registry::get('configDatabase')->version;
65+
return array('version' => Zend_Registry::get('configDatabase')->version);
66+
}
67+
68+
/**
69+
* Get the enabled modules on the server
70+
* @return List of enabled modules on the server
71+
*/
72+
public function modulesList($args)
73+
{
74+
return array('modules' => array_keys(Zend_Registry::get('configsModules')));
75+
}
76+
77+
/**
78+
* List all available web api methods on the server
79+
* @return List of api method names and their corresponding documentation
80+
*/
81+
public function methodsList($args)
82+
{
83+
$data = array();
84+
$data['methods'] = array();
85+
86+
$apiMethods = Zend_Registry::get('notifier')->callback('CALLBACK_API_HELP', array());
87+
foreach($apiMethods as $module => $methods)
88+
{
89+
foreach($methods as $method)
90+
{
91+
$apiMethodName = $module != 'api' ? $module.'.' : '';
92+
$apiMethodName .= $method['name'];
93+
$data['methods'][] = array('name' => $apiMethodName, 'help' => $method['help']);
94+
}
95+
}
6696
return $data;
6797
}
6898

6999
/**
70-
* Get the server information
100+
* Get the server information including version, modules enabled,
101+
and available web api methods (names do not include the global prefix)
71102
* @return Server information
72103
*/
73104
public function info($args)
74105
{
75-
$data['version'] = Zend_Registry::get('configDatabase')->version;
76-
return $data;
106+
return array_merge($this->version($args),
107+
$this->modulesList($args),
108+
$this->methodsList($args));
77109
}
78110

79111
/**

0 commit comments

Comments
 (0)