summaryrefslogtreecommitdiff
path: root/res/ari
diff options
context:
space:
mode:
authorBenjamin Ford <bford@digium.com>2015-07-14 08:55:14 -0500
committerBenjamin Ford <bford@digium.com>2015-07-14 08:57:57 -0500
commit9dcae23cfceedece83568d2194df00ca62f7d53c (patch)
tree7c1865ee0b08507d3e9df6e742d61a71fba06760 /res/ari
parentc219a98d2b46a61996518fd2791b7bb4437969fb (diff)
ARI: Added new functionality to unload a single module.
An http request can be sent to unload an Asterisk module. If the module can not be unloaded or is already unloaded, an error response will be returned. The command "curl -v -u user:pass -X DELETE '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 * Asterisk modules can be unloaded through http requests ASTERISK-25173 Change-Id: I535a95f5676deb02651522761ecbdc0b00b5ac57
Diffstat (limited to 'res/ari')
-rw-r--r--res/ari/resource_asterisk.c28
-rw-r--r--res/ari/resource_asterisk.h13
2 files changed, 41 insertions, 0 deletions
diff --git a/res/ari/resource_asterisk.c b/res/ari/resource_asterisk.c
index 242279867..4c2948d2b 100644
--- a/res/ari/resource_asterisk.c
+++ b/res/ari/resource_asterisk.c
@@ -295,6 +295,34 @@ void ast_ari_asterisk_load_module(struct ast_variable *headers,
ast_ari_response_no_content(response);
}
+void ast_ari_asterisk_unload_module(struct ast_variable *headers,
+ struct ast_ari_asterisk_unload_module_args *args,
+ struct ast_ari_response *response)
+{
+ int unload_result;
+ enum ast_module_unload_mode unload_mode = AST_FORCE_FIRM;
+
+ ast_assert(response != NULL);
+
+ if (!ast_module_check(args->module_name)) {
+ ast_ari_response_error(
+ response, 404, "Not Found",
+ "Module not found in running modules");
+ return;
+ }
+
+ unload_result = ast_unload_resource(args->module_name, unload_mode);
+
+ if (unload_result != 0) {
+ ast_ari_response_error(
+ response, 409, "Conflict",
+ "Module could not be unloaded");
+ return;
+ }
+
+ ast_ari_response_no_content(response);
+}
+
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)
diff --git a/res/ari/resource_asterisk.h b/res/ari/resource_asterisk.h
index 5846a7120..5e3ff9b15 100644
--- a/res/ari/resource_asterisk.h
+++ b/res/ari/resource_asterisk.h
@@ -104,6 +104,19 @@ struct ast_ari_asterisk_load_module_args {
* \param[out] response HTTP response
*/
void ast_ari_asterisk_load_module(struct ast_variable *headers, struct ast_ari_asterisk_load_module_args *args, struct ast_ari_response *response);
+/*! Argument struct for ast_ari_asterisk_unload_module() */
+struct ast_ari_asterisk_unload_module_args {
+ /*! Module's name */
+ const char *module_name;
+};
+/*!
+ * \brief Unload an Asterisk module.
+ *
+ * \param headers HTTP headers
+ * \param args Swagger parameters
+ * \param[out] response HTTP response
+ */
+void ast_ari_asterisk_unload_module(struct ast_variable *headers, struct ast_ari_asterisk_unload_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 */