mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
ARI: Added new functionality to get information on a single module.
An http request can be sent to retrieve information on a single module, including the resource name, description, use count, status, and support level. The command "curl -v -u user:pass -X GET 'http://localhost:8088/ari /asterisk/modules/{moduleName}'" (or something similar, depending on configuration) can be run in the terminal to access this new functionality. For more information, see: https://wiki.asterisk.org/wiki.display/~bford/Asterisk+ARI+Resource * Added new ARI functionality * Information on a single module can now be retrieved ASTERISK-25173 Change-Id: Ibce5a94e70ecdf4e90329cf0ba66c33a62d37463
This commit is contained in:
@@ -185,6 +185,79 @@ void ast_ari_asterisk_list_modules(struct ast_variable *headers,
|
||||
ast_ari_response_ok(response, json);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Identify module by name and process resource information
|
||||
* \param module Resource name
|
||||
* \param description Resource description
|
||||
* \param usecnt Resource use count
|
||||
* \param status Resource running status
|
||||
* \param like
|
||||
* \param support_level Resource support level
|
||||
* \param data JSON body for resource
|
||||
* \param condition Name to match resource to
|
||||
*
|
||||
* \retval 0 if no resource exists
|
||||
* \retval 1 if resource exists
|
||||
*/
|
||||
static int identify_module(const char *module, const char *description, int usecnt,
|
||||
const char *status, const char *like,
|
||||
enum ast_module_support_level support_level, void *data,
|
||||
const char *condition)
|
||||
{
|
||||
int json_obj_set = 0;
|
||||
|
||||
if (strcmp(condition, module) != 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
json_obj_set += ast_json_object_set(data, "name", ast_json_string_create(module));
|
||||
json_obj_set += ast_json_object_set(data, "description", ast_json_string_create(description));
|
||||
json_obj_set += ast_json_object_set(data, "use_count", ast_json_integer_create(usecnt));
|
||||
json_obj_set += ast_json_object_set(data, "status", ast_json_string_create(status));
|
||||
json_obj_set += ast_json_object_set(data, "support_level", ast_json_string_create(
|
||||
ast_module_support_level_to_string(support_level)));
|
||||
|
||||
if (json_obj_set != 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ast_ari_asterisk_get_module(struct ast_variable *headers,
|
||||
struct ast_ari_asterisk_get_module_args *args,
|
||||
struct ast_ari_response *response)
|
||||
{
|
||||
struct ast_json *json;
|
||||
int module_retrieved = 0;
|
||||
|
||||
ast_assert(response != NULL);
|
||||
|
||||
if (!ast_module_check(args->module_name)) {
|
||||
ast_ari_response_error(
|
||||
response, 404, "Not Found",
|
||||
"Module could not be found in running modules");
|
||||
return;
|
||||
}
|
||||
|
||||
json = ast_json_object_create();
|
||||
if (!json) {
|
||||
ast_ari_response_alloc_failed(response);
|
||||
return;
|
||||
}
|
||||
|
||||
module_retrieved = ast_update_module_list_condition(&identify_module, NULL, json,
|
||||
args->module_name);
|
||||
if (!module_retrieved) {
|
||||
ast_ari_response_error(
|
||||
response, 409, "Conflict",
|
||||
"Module information could not be retrieved");
|
||||
return;
|
||||
}
|
||||
|
||||
ast_ari_response_ok(response, json);
|
||||
}
|
||||
|
||||
void ast_ari_asterisk_get_global_var(struct ast_variable *headers,
|
||||
struct ast_ari_asterisk_get_global_var_args *args,
|
||||
struct ast_ari_response *response)
|
||||
|
@@ -78,6 +78,19 @@ struct ast_ari_asterisk_list_modules_args {
|
||||
* \param[out] response HTTP response
|
||||
*/
|
||||
void ast_ari_asterisk_list_modules(struct ast_variable *headers, struct ast_ari_asterisk_list_modules_args *args, struct ast_ari_response *response);
|
||||
/*! Argument struct for ast_ari_asterisk_get_module() */
|
||||
struct ast_ari_asterisk_get_module_args {
|
||||
/*! Module's name */
|
||||
const char *module_name;
|
||||
};
|
||||
/*!
|
||||
* \brief Get Asterisk module information.
|
||||
*
|
||||
* \param headers HTTP headers
|
||||
* \param args Swagger parameters
|
||||
* \param[out] response HTTP response
|
||||
*/
|
||||
void ast_ari_asterisk_get_module(struct ast_variable *headers, struct ast_ari_asterisk_get_module_args *args, struct ast_ari_response *response);
|
||||
/*! Argument struct for ast_ari_asterisk_get_global_var() */
|
||||
struct ast_ari_asterisk_get_global_var_args {
|
||||
/*! The variable to get */
|
||||
|
Reference in New Issue
Block a user