Asterisk - The Open Source Telephony Project
18.5.0
|
HTTP binding for the Stasis API. More...
#include "asterisk.h"
#include "ari/internal.h"
#include "asterisk/ari.h"
#include "asterisk/astobj2.h"
#include "asterisk/module.h"
#include "asterisk/paths.h"
#include "asterisk/stasis_app.h"
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
Go to the source code of this file.
Macros | |
#define | ACA_HEADERS "Access-Control-Allow-Headers" |
#define | ACA_METHODS "Access-Control-Allow-Methods" |
#define | ACR_HEADERS "Access-Control-Request-Headers" |
#define | ACR_METHOD "Access-Control-Request-Method" |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static void | add_allow_header (struct stasis_rest_handlers *handler, struct ast_ari_response *response) |
int | ast_ari_add_handler (struct stasis_rest_handlers *handler) |
static int | ast_ari_callback (struct ast_tcptls_session_instance *ser, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_params, struct ast_variable *headers) |
void | ast_ari_get_docs (const char *uri, const char *prefix, struct ast_variable *headers, struct ast_ari_response *response) |
void | ast_ari_invoke (struct ast_tcptls_session_instance *ser, const char *uri, enum ast_http_method method, struct ast_variable *get_params, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response) |
enum ast_json_encoding_format | ast_ari_json_format (void) |
Configured encoding format for JSON output. More... | |
struct ast_json * | ast_ari_oom_json (void) |
The stock message to return when out of memory. More... | |
int | ast_ari_remove_handler (struct stasis_rest_handlers *handler) |
void | ast_ari_response_accepted (struct ast_ari_response *response) |
Fill in a Accepted (202) ast_ari_response. More... | |
void | ast_ari_response_alloc_failed (struct ast_ari_response *response) |
Fill in response with a 500 message for allocation failures. More... | |
void | ast_ari_response_created (struct ast_ari_response *response, const char *url, struct ast_json *message) |
Fill in a Created (201) ast_ari_response. More... | |
void | ast_ari_response_error (struct ast_ari_response *response, int response_code, const char *response_text, const char *message_fmt,...) |
Fill in an error ast_ari_response. More... | |
void | ast_ari_response_no_content (struct ast_ari_response *response) |
Fill in a No Content (204) ast_ari_response. More... | |
void | ast_ari_response_ok (struct ast_ari_response *response, struct ast_json *message) |
Fill in an OK (200) ast_ari_response. More... | |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
static struct ast_ari_conf_user * | authenticate_api_key (const char *api_key) |
Authenticate a ?api_key=userid:password More... | |
static struct ast_ari_conf_user * | authenticate_user (struct ast_variable *get_params, struct ast_variable *headers) |
Authenticate an HTTP request. More... | |
static struct stasis_rest_handlers * | get_root_handler (void) |
static void | handle_options (struct stasis_rest_handlers *handler, struct ast_variable *headers, struct ast_ari_response *response) |
Handle OPTIONS request, mainly for CORS preflight requests. More... | |
static int | is_enabled (void) |
Helper function to check if module is enabled. More... | |
static int | load_module (void) |
static int | origin_allowed (const char *origin) |
static void | process_cors_request (struct ast_variable *headers, struct ast_ari_response *response) |
Handle CORS headers for simple requests. More... | |
static int | reload_module (void) |
static void | remove_trailing_slash (const char *uri, struct ast_ari_response *response) |
static struct stasis_rest_handlers * | root_handler_create (void) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "Asterisk RESTful Interface" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "30ef0c93b36035ec78c9cfd712d36d9b" , .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .reload = reload_module, .optional_modules = "res_http_websocket", .requires = "http,res_stasis", .load_pri = AST_MODPRI_APP_DEPEND, } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_http_uri | http_uri |
static struct ast_json * | oom_json |
static struct stasis_rest_handlers * | root_handler |
static ast_mutex_t | root_handler_lock |
HTTP binding for the Stasis API.
The API itself is documented using Swagger, a lightweight mechanism for documenting RESTful API's using JSON. This allows us to use swagger-ui to provide executable documentation for the API, generate client bindings in different languages, and generate a lot of the boilerplate code for implementing the RESTful bindings. The API docs live in the rest-api/
directory.
The RESTful bindings are generated from the Swagger API docs using a set of Mustache templates. The code generator is written in Python, and uses the Python implementation pystache. Pystache has no dependencies, and be installed easily using pip
. Code generation code lives in rest-api-templates/
.
The generated code reduces a lot of boilerplate when it comes to handling HTTP requests. It also helps us have greater consistency in the REST API.
The structure of the generated code is:
*_args
which is passed to the specific request handler (in res/ari/resource_{resource}.c)The basic flow of an HTTP request is:
ast_ari_*_cb
*_args
struct with path and get paramsDefinition in file res_ari.c.
#define ACA_HEADERS "Access-Control-Allow-Headers" |
Definition at line 353 of file res_ari.c.
Referenced by handle_options().
#define ACA_METHODS "Access-Control-Allow-Methods" |
Definition at line 352 of file res_ari.c.
Referenced by handle_options().
#define ACR_HEADERS "Access-Control-Request-Headers" |
Definition at line 351 of file res_ari.c.
Referenced by handle_options().
#define ACR_METHOD "Access-Control-Request-Method" |
Definition at line 350 of file res_ari.c.
Referenced by handle_options().
|
static |
Definition at line 315 of file res_ari.c.
References ast_get_http_method(), AST_HTTP_MAX_METHOD, ast_str_append(), stasis_rest_handlers::callbacks, ast_ari_response::headers, and NULL.
Referenced by ast_ari_invoke(), and handle_options().
int ast_ari_add_handler | ( | struct stasis_rest_handlers * | handler | ) |
Add a resource for REST handling.
handler | Handler to add. |
Definition at line 179 of file res_ari.c.
References ao2_alloc, ao2_cleanup, ao2_ref, handler(), lock, NULL, stasis_rest_handlers::num_children, RAII_VAR, and SCOPED_MUTEX.
Referenced by load_module(), and setup_invocation_test().
|
static |
Definition at line 885 of file res_ari.c.
References ao2_cleanup, app, app_name(), ast_ari_config_get(), ast_ari_get_docs(), ast_ari_invoke(), ast_ari_json_format(), ast_ari_response_error(), ast_assert, ast_begins_with(), ast_ends_with(), ast_free, ast_fully_booted, ast_http_error(), AST_HTTP_GET, ast_http_get_json(), ast_http_get_post_vars(), AST_HTTP_OPTIONS, ast_http_request_close_on_completion(), ast_http_send(), ast_json_dump_str_format(), ast_json_dump_string_format(), ast_json_free(), ast_json_is_null(), ast_json_null(), ast_json_object_get(), ast_json_string_get(), ast_json_unref(), ast_sockaddr_stringify(), ast_str_append(), ast_str_buffer(), ast_str_create, ast_str_set(), ast_variable_find_in_list(), ast_variables_destroy(), ast_variables_dup(), ast_verbose(), authenticate_user(), buf, errno, ast_ari_response::fd, ast_ari_response::headers, ast_ari_response::message, ast_variable::name, ast_variable::next, ast_ari_response::no_response, NULL, ast_http_uri::prefix, process_cors_request(), RAII_VAR, ast_tcptls_session_instance::remote_address, remove_trailing_slash(), ast_ari_response::response_code, ast_ari_response::response_text, S_OR, stasis_app_get_debug_by_name(), str, ast_variable::value, and var.
void ast_ari_get_docs | ( | const char * | uri, |
const char * | prefix, | ||
struct ast_variable * | headers, | ||
struct ast_ari_response * | response | ||
) |
Definition at line 598 of file res_ari.c.
References ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_response_ok(), ast_begins_with(), ast_config_AST_DATA_DIR, ast_debug, ast_free, ast_json_load_new_file(), ast_json_object_del(), ast_json_object_get(), ast_json_object_set(), ast_json_stringf(), ast_log, ast_std_free(), ast_str_append(), ast_str_buffer(), ast_str_create, ast_json_error::column, errno, host, ast_json_error::line, LOG_ERROR, ast_variable::name, ast_variable::next, NULL, RAII_VAR, ast_json_error::source, ast_json_error::text, and ast_variable::value.
Referenced by ast_ari_callback(), and AST_TEST_DEFINE().
void ast_ari_invoke | ( | struct ast_tcptls_session_instance * | ser, |
const char * | uri, | ||
enum ast_http_method | method, | ||
struct ast_variable * | get_params, | ||
struct ast_variable * | headers, | ||
struct ast_json * | body, | ||
struct ast_ari_response * | response | ||
) |
Definition at line 491 of file res_ari.c.
References add_allow_header(), ao2_cleanup, ari_handle_websocket(), ast_ari_response_error(), ast_assert, ast_debug, ast_get_http_method(), AST_HTTP_GET, AST_HTTP_MAX_METHOD, AST_HTTP_OPTIONS, ast_log, ast_strdupa, ast_uri_decode(), ast_uri_http_legacy, ast_variable_new, ast_variables_destroy(), stasis_rest_handlers::callbacks, stasis_rest_handlers::children, get_root_handler(), handle_options(), handler(), stasis_rest_handlers::is_wildcard, LOG_ERROR, ast_ari_response::message, method, ast_variable::next, ast_ari_response::no_response, NULL, stasis_rest_handlers::num_children, stasis_rest_handlers::path_segment, RAII_VAR, ast_ari_response::response_code, strsep(), and stasis_rest_handlers::ws_server.
Referenced by ast_ari_callback(), and AST_TEST_DEFINE().
enum ast_json_encoding_format ast_ari_json_format | ( | void | ) |
Configured encoding format for JSON output.
Definition at line 806 of file res_ari.c.
References ao2_cleanup, ast_ari_config_get(), NULL, and RAII_VAR.
Referenced by ast_ari_callback(), ast_ari_websocket_session_write(), and stasis_app_message_handler().
struct ast_json* ast_ari_oom_json | ( | void | ) |
The stock message to return when out of memory.
The refcount is NOT bumped on this object, so ast_json_ref() if you want to keep the reference.
Definition at line 174 of file res_ari.c.
References oom_json.
int ast_ari_remove_handler | ( | struct stasis_rest_handlers * | handler | ) |
Remove a resource for REST handling.
handler | Handler to add. |
Definition at line 202 of file res_ari.c.
References ao2_alloc, ao2_cleanup, ast_assert, ast_mutex_lock, ast_mutex_unlock, stasis_rest_handlers::children, handler(), NULL, and stasis_rest_handlers::num_children.
Referenced by tear_down_invocation_test(), and unload_module().
void ast_ari_response_accepted | ( | struct ast_ari_response * | response | ) |
Fill in a Accepted
(202) ast_ari_response.
Definition at line 291 of file res_ari.c.
References ast_json_null(), ast_ari_response::message, ast_ari_response::response_code, and ast_ari_response::response_text.
Referenced by ast_ari_asterisk_reload_module().
void ast_ari_response_alloc_failed | ( | struct ast_ari_response * | response | ) |
Fill in response with a 500 message for allocation failures.
response | Response to fill in. |
Definition at line 298 of file res_ari.c.
References ast_json_ref(), ast_ari_response::message, ast_ari_response::response_code, and ast_ari_response::response_text.
Referenced by ari_bridges_play_helper(), ari_bridges_play_new(), ari_channels_handle_originate_with_id(), ast_ari_applications_subscribe_cb(), ast_ari_applications_unsubscribe_cb(), ast_ari_asterisk_add_log_cb(), ast_ari_asterisk_get_global_var(), ast_ari_asterisk_get_global_var_cb(), ast_ari_asterisk_get_info(), ast_ari_asterisk_get_info_cb(), ast_ari_asterisk_get_module(), ast_ari_asterisk_list_modules(), ast_ari_asterisk_set_global_var_cb(), ast_ari_asterisk_update_object(), ast_ari_bridges_add_channel(), ast_ari_bridges_add_channel_cb(), ast_ari_bridges_create_cb(), ast_ari_bridges_create_with_id_cb(), ast_ari_bridges_list(), ast_ari_bridges_play_cb(), ast_ari_bridges_play_with_id_cb(), ast_ari_bridges_record(), ast_ari_bridges_record_cb(), ast_ari_bridges_remove_channel_cb(), ast_ari_bridges_start_moh(), ast_ari_bridges_start_moh_cb(), ast_ari_channels_continue_in_dialplan(), ast_ari_channels_continue_in_dialplan_cb(), ast_ari_channels_create(), ast_ari_channels_dial(), ast_ari_channels_dial_cb(), ast_ari_channels_get_channel_var(), ast_ari_channels_get_channel_var_cb(), ast_ari_channels_hangup_cb(), ast_ari_channels_list(), ast_ari_channels_move_cb(), ast_ari_channels_mute_cb(), ast_ari_channels_play_cb(), ast_ari_channels_play_with_id_cb(), ast_ari_channels_record_cb(), ast_ari_channels_redirect_cb(), ast_ari_channels_send_dtmf_cb(), ast_ari_channels_set_channel_var_cb(), ast_ari_channels_snoop_channel_cb(), ast_ari_channels_snoop_channel_with_id_cb(), ast_ari_channels_start_moh_cb(), ast_ari_channels_unmute_cb(), ast_ari_device_states_update_cb(), ast_ari_endpoints_get(), ast_ari_endpoints_list(), ast_ari_endpoints_list_by_tech(), ast_ari_events_event_websocket_ws_attempted_cb(), ast_ari_events_event_websocket_ws_established_cb(), ast_ari_events_user_event_cb(), ast_ari_get_docs(), ast_ari_mailboxes_update_cb(), ast_ari_playbacks_control_cb(), ast_ari_recordings_copy_stored_cb(), ast_ari_recordings_list_stored(), ast_ari_sounds_list_cb(), control_list_create(), handle_options(), json_to_ast_variables(), return_sorcery_object(), and send_message().
void ast_ari_response_created | ( | struct ast_ari_response * | response, |
const char * | url, | ||
struct ast_json * | message | ||
) |
Fill in a Created
(201) ast_ari_response.
response | Response to fill in. |
url | URL to the created resource. |
message | JSON response. This reference is stolen, so just ast_json_ref if you need to keep a reference to it. |
Definition at line 305 of file res_ari.c.
References ao2_cleanup, ast_str_append(), get_root_handler(), ast_ari_response::headers, ast_ari_response::message, RAII_VAR, ast_ari_response::response_code, and ast_ari_response::response_text.
Referenced by ari_bridges_play_found(), ari_bridges_play_new(), ari_channels_handle_play(), ast_ari_bridges_record(), and ast_ari_channels_record().
void ast_ari_response_error | ( | struct ast_ari_response * | response, |
int | response_code, | ||
const char * | response_text, | ||
const char * | message_fmt, | ||
... | |||
) |
Fill in an error ast_ari_response.
response | Response to fill in. |
response_code | HTTP response code. |
response_text | Text corresponding to the HTTP response code. |
message_fmt | Error message format string. |
Definition at line 259 of file res_ari.c.
References ast_json_pack(), ast_json_ref(), ast_json_unref(), ast_json_vstringf(), ast_ari_response::message, NULL, RAII_VAR, ast_ari_response::response_code, and ast_ari_response::response_text.
Referenced by ari_bridges_play_helper(), ari_bridges_play_new(), ari_channels_handle_originate_with_id(), ari_channels_handle_play(), ari_channels_handle_snoop_channel(), ast_ari_applications_filter(), ast_ari_applications_filter_cb(), ast_ari_applications_get(), ast_ari_applications_get_cb(), ast_ari_applications_list(), ast_ari_applications_list_cb(), ast_ari_applications_subscribe(), ast_ari_applications_subscribe_cb(), ast_ari_applications_unsubscribe(), ast_ari_applications_unsubscribe_cb(), ast_ari_asterisk_add_log(), ast_ari_asterisk_add_log_cb(), ast_ari_asterisk_delete_log(), ast_ari_asterisk_delete_log_cb(), ast_ari_asterisk_delete_object(), ast_ari_asterisk_delete_object_cb(), ast_ari_asterisk_get_global_var(), ast_ari_asterisk_get_global_var_cb(), ast_ari_asterisk_get_info_cb(), ast_ari_asterisk_get_module(), ast_ari_asterisk_get_module_cb(), ast_ari_asterisk_get_object(), ast_ari_asterisk_get_object_cb(), ast_ari_asterisk_list_log_channels(), ast_ari_asterisk_list_log_channels_cb(), ast_ari_asterisk_list_modules_cb(), ast_ari_asterisk_load_module(), ast_ari_asterisk_load_module_cb(), ast_ari_asterisk_ping_cb(), ast_ari_asterisk_reload_module(), ast_ari_asterisk_reload_module_cb(), ast_ari_asterisk_rotate_log(), ast_ari_asterisk_rotate_log_cb(), ast_ari_asterisk_set_global_var(), ast_ari_asterisk_set_global_var_cb(), ast_ari_asterisk_unload_module(), ast_ari_asterisk_unload_module_cb(), ast_ari_asterisk_update_object(), ast_ari_asterisk_update_object_cb(), ast_ari_bridges_add_channel_cb(), ast_ari_bridges_clear_video_source_cb(), ast_ari_bridges_create(), ast_ari_bridges_create_cb(), ast_ari_bridges_create_with_id(), ast_ari_bridges_create_with_id_cb(), ast_ari_bridges_destroy_cb(), ast_ari_bridges_get(), ast_ari_bridges_get_cb(), ast_ari_bridges_list_cb(), ast_ari_bridges_play_cb(), ast_ari_bridges_play_with_id_cb(), ast_ari_bridges_record(), ast_ari_bridges_record_cb(), ast_ari_bridges_remove_channel(), ast_ari_bridges_remove_channel_cb(), ast_ari_bridges_set_video_source(), ast_ari_bridges_set_video_source_cb(), ast_ari_bridges_start_moh_cb(), ast_ari_bridges_stop_moh(), ast_ari_bridges_stop_moh_cb(), ast_ari_callback(), ast_ari_channels_answer(), ast_ari_channels_answer_cb(), ast_ari_channels_continue_in_dialplan(), ast_ari_channels_continue_in_dialplan_cb(), ast_ari_channels_create(), ast_ari_channels_create_cb(), ast_ari_channels_dial(), ast_ari_channels_dial_cb(), ast_ari_channels_external_media(), ast_ari_channels_external_media_cb(), ast_ari_channels_get(), ast_ari_channels_get_cb(), ast_ari_channels_get_channel_var(), ast_ari_channels_get_channel_var_cb(), ast_ari_channels_hangup(), ast_ari_channels_hangup_cb(), ast_ari_channels_hold_cb(), ast_ari_channels_list_cb(), ast_ari_channels_move(), ast_ari_channels_move_cb(), ast_ari_channels_mute(), ast_ari_channels_mute_cb(), ast_ari_channels_originate_cb(), ast_ari_channels_originate_with_id_cb(), ast_ari_channels_play_cb(), ast_ari_channels_play_with_id_cb(), ast_ari_channels_record(), ast_ari_channels_record_cb(), ast_ari_channels_redirect(), ast_ari_channels_redirect_cb(), ast_ari_channels_ring_cb(), ast_ari_channels_ring_stop_cb(), ast_ari_channels_rtpstatistics(), ast_ari_channels_rtpstatistics_cb(), ast_ari_channels_send_dtmf(), ast_ari_channels_send_dtmf_cb(), ast_ari_channels_set_channel_var(), ast_ari_channels_set_channel_var_cb(), ast_ari_channels_snoop_channel_cb(), ast_ari_channels_snoop_channel_with_id_cb(), ast_ari_channels_start_moh_cb(), ast_ari_channels_start_silence_cb(), ast_ari_channels_stop_moh_cb(), ast_ari_channels_stop_silence_cb(), ast_ari_channels_unhold_cb(), ast_ari_channels_unmute(), ast_ari_channels_unmute_cb(), ast_ari_device_states_delete(), ast_ari_device_states_delete_cb(), ast_ari_device_states_get(), ast_ari_device_states_get_cb(), ast_ari_device_states_list(), ast_ari_device_states_list_cb(), ast_ari_device_states_update(), ast_ari_device_states_update_cb(), ast_ari_endpoints_get(), ast_ari_endpoints_get_cb(), ast_ari_endpoints_list(), ast_ari_endpoints_list_by_tech(), ast_ari_endpoints_list_by_tech_cb(), ast_ari_endpoints_list_cb(), ast_ari_endpoints_send_message_cb(), ast_ari_endpoints_send_message_to_endpoint(), ast_ari_endpoints_send_message_to_endpoint_cb(), ast_ari_events_event_websocket_ws_attempted_cb(), ast_ari_events_event_websocket_ws_established_cb(), ast_ari_events_user_event(), ast_ari_events_user_event_cb(), ast_ari_get_docs(), ast_ari_invoke(), ast_ari_mailboxes_delete(), ast_ari_mailboxes_delete_cb(), ast_ari_mailboxes_get(), ast_ari_mailboxes_get_cb(), ast_ari_mailboxes_list(), ast_ari_mailboxes_list_cb(), ast_ari_mailboxes_update(), ast_ari_mailboxes_update_cb(), ast_ari_playbacks_control(), ast_ari_playbacks_control_cb(), ast_ari_playbacks_get(), ast_ari_playbacks_get_cb(), ast_ari_playbacks_stop(), ast_ari_playbacks_stop_cb(), ast_ari_recordings_cancel_cb(), ast_ari_recordings_copy_stored(), ast_ari_recordings_copy_stored_cb(), ast_ari_recordings_delete_stored(), ast_ari_recordings_delete_stored_cb(), ast_ari_recordings_get_live(), ast_ari_recordings_get_live_cb(), ast_ari_recordings_get_stored(), ast_ari_recordings_get_stored_cb(), ast_ari_recordings_get_stored_file(), ast_ari_recordings_get_stored_file_cb(), ast_ari_recordings_list_stored_cb(), ast_ari_recordings_mute_cb(), ast_ari_recordings_pause_cb(), ast_ari_recordings_stop_cb(), ast_ari_recordings_unmute_cb(), ast_ari_recordings_unpause_cb(), ast_ari_sounds_get(), ast_ari_sounds_get_cb(), ast_ari_sounds_list(), ast_ari_sounds_list_cb(), channel_state_invalid(), check_add_remove_channel(), control_list_create(), control_recording(), find_bridge(), find_channel_control(), find_control(), json_to_ast_variables(), remove_trailing_slash(), and send_message().
void ast_ari_response_no_content | ( | struct ast_ari_response * | response | ) |
Fill in a No Content
(204) ast_ari_response.
Definition at line 284 of file res_ari.c.
References ast_json_null(), ast_ari_response::message, ast_ari_response::response_code, and ast_ari_response::response_text.
Referenced by ast_ari_asterisk_add_log(), ast_ari_asterisk_delete_log(), ast_ari_asterisk_delete_object(), ast_ari_asterisk_load_module(), ast_ari_asterisk_reload_module(), ast_ari_asterisk_rotate_log(), ast_ari_asterisk_set_global_var(), ast_ari_asterisk_unload_module(), ast_ari_bridges_add_channel(), ast_ari_bridges_clear_video_source(), ast_ari_bridges_destroy(), ast_ari_bridges_remove_channel(), ast_ari_bridges_set_video_source(), ast_ari_bridges_start_moh(), ast_ari_bridges_stop_moh(), ast_ari_channels_answer(), ast_ari_channels_continue_in_dialplan(), ast_ari_channels_dial(), ast_ari_channels_hangup(), ast_ari_channels_hold(), ast_ari_channels_move(), ast_ari_channels_mute(), ast_ari_channels_redirect(), ast_ari_channels_ring(), ast_ari_channels_ring_stop(), ast_ari_channels_send_dtmf(), ast_ari_channels_set_channel_var(), ast_ari_channels_start_moh(), ast_ari_channels_start_silence(), ast_ari_channels_stop_moh(), ast_ari_channels_stop_silence(), ast_ari_channels_unhold(), ast_ari_channels_unmute(), ast_ari_device_states_delete(), ast_ari_device_states_update(), ast_ari_events_user_event(), ast_ari_mailboxes_delete(), ast_ari_mailboxes_update(), ast_ari_playbacks_control(), ast_ari_playbacks_stop(), ast_ari_recordings_delete_stored(), control_recording(), and handle_options().
void ast_ari_response_ok | ( | struct ast_ari_response * | response, |
struct ast_json * | message | ||
) |
Fill in an OK
(200) ast_ari_response.
response | Response to fill in. |
message | JSON response. This reference is stolen, so just ast_json_ref if you need to keep a reference to it. |
Definition at line 276 of file res_ari.c.
References ast_ari_response::message, ast_ari_response::response_code, and ast_ari_response::response_text.
Referenced by ari_channels_handle_originate_with_id(), ari_channels_handle_snoop_channel(), ast_ari_applications_filter(), ast_ari_applications_get(), ast_ari_applications_list(), ast_ari_applications_subscribe(), ast_ari_applications_unsubscribe(), ast_ari_asterisk_get_global_var(), ast_ari_asterisk_get_info(), ast_ari_asterisk_get_module(), ast_ari_asterisk_list_log_channels(), ast_ari_asterisk_list_modules(), ast_ari_asterisk_ping(), ast_ari_bridges_create(), ast_ari_bridges_create_with_id(), ast_ari_bridges_get(), ast_ari_bridges_list(), ast_ari_channels_create(), ast_ari_channels_get(), ast_ari_channels_get_channel_var(), ast_ari_channels_list(), ast_ari_channels_rtpstatistics(), ast_ari_device_states_get(), ast_ari_device_states_list(), ast_ari_endpoints_get(), ast_ari_endpoints_list(), ast_ari_endpoints_list_by_tech(), ast_ari_get_docs(), ast_ari_mailboxes_get(), ast_ari_mailboxes_list(), ast_ari_playbacks_get(), ast_ari_recordings_copy_stored(), ast_ari_recordings_get_live(), ast_ari_recordings_get_stored(), ast_ari_recordings_get_stored_file(), ast_ari_recordings_list_stored(), ast_ari_sounds_get(), ast_ari_sounds_list(), and return_sorcery_object().
struct ast_module* AST_MODULE_SELF_SYM | ( | void | ) |
|
static |
Authenticate a ?api_key=userid:password
api_key | API key query parameter |
NULL
if authentication failed. Definition at line 820 of file res_ari.c.
References ast_ari_config_validate_user(), ast_free, ast_log, ast_strdup, copy(), LOG_WARNING, NULL, password, RAII_VAR, strsep(), and ast_ari_conf_user::username.
Referenced by authenticate_user().
|
static |
Authenticate an HTTP request.
get_params | GET parameters of the request. |
header | HTTP headers. |
NULL
if authentication failed. Definition at line 848 of file res_ari.c.
References ao2_cleanup, ast_ari_config_validate_user(), ast_http_get_auth(), authenticate_api_key(), ast_variable::name, ast_variable::next, NULL, RAII_VAR, and ast_variable::value.
Referenced by ast_ari_callback().
|
static |
Definition at line 238 of file res_ari.c.
References ao2_ref, lock, root_handler, and SCOPED_MUTEX.
Referenced by ast_ari_invoke(), and ast_ari_response_created().
|
static |
Handle OPTIONS request, mainly for CORS preflight requests.
Some browsers will send this prior to non-simple methods (i.e. DELETE). See http://www.w3.org/TR/cors/ for the spec. Especially section 6.2.
Definition at line 361 of file res_ari.c.
References ACA_HEADERS, ACA_METHODS, ACR_HEADERS, ACR_METHOD, add_allow_header(), ast_ari_response_alloc_failed(), ast_ari_response_no_content(), ast_free, ast_get_http_method(), AST_HTTP_MAX_METHOD, ast_log, ast_str_append(), ast_str_buffer(), ast_str_create, ast_strlen_zero, stasis_rest_handlers::callbacks, ast_ari_response::headers, LOG_NOTICE, ast_variable::name, ast_variable::next, NULL, origin_allowed(), RAII_VAR, and ast_variable::value.
Referenced by ast_ari_invoke().
|
static |
Helper function to check if module is enabled.
Definition at line 159 of file res_ari.c.
References ao2_cleanup, ast_ari_config_get(), and RAII_VAR.
Referenced by ast_cel_set_config(), load_module(), reload_module(), and unload_module().
|
static |
Definition at line 1144 of file res_ari.c.
References ast_ari_cli_register(), ast_ari_config_init(), ast_debug, ast_http_uri_link(), ast_json_pack(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_mutex_init, is_enabled(), root_handler_create(), and unload_module().
Referenced by reload_module().
|
static |
Definition at line 330 of file res_ari.c.
References ao2_cleanup, ast_ari_config_get(), ast_strdupa, RAII_VAR, and strsep().
Referenced by handle_options(), and process_cors_request().
|
static |
Handle CORS headers for simple requests.
See http://www.w3.org/TR/cors/ for the spec. Especially section 6.1.
Definition at line 753 of file res_ari.c.
References ast_log, ast_str_append(), ast_ari_response::headers, LOG_NOTICE, ast_variable::name, ast_variable::next, NULL, origin_allowed(), and ast_variable::value.
Referenced by ast_ari_callback().
|
static |
Definition at line 1187 of file res_ari.c.
References ast_ari_config_reload(), ast_debug, ast_http_uri_link(), ast_http_uri_unlink(), AST_MODFLAG_GLOBAL_SYMBOLS, AST_MODFLAG_LOAD_ORDER, AST_MODPRI_APP_DEPEND, AST_MODULE_INFO(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, AST_MODULE_SUPPORT_CORE, ASTERISK_GPL_KEY, is_enabled(), load_module(), reload(), and unload_module().
|
static |
Definition at line 722 of file res_ari.c.
References ast_ari_response_error(), and ast_strdupa.
Referenced by ast_ari_callback().
|
static |
Definition at line 245 of file res_ari.c.
References ao2_alloc, ao2_cleanup, ao2_ref, handler(), NULL, and RAII_VAR.
Referenced by load_module().
|
static |
Definition at line 1123 of file res_ari.c.
References ao2_cleanup, ast_ari_cli_unregister(), ast_ari_config_destroy(), ast_debug, ast_http_uri_unlink(), ast_json_unref(), ast_mutex_destroy, is_enabled(), and NULL.
Referenced by load_module(), and reload_module().
|
static |
|
static |
|
static |
|
static |
Pre-defined message for allocation failures.
Definition at line 172 of file res_ari.c.
Referenced by ast_ari_oom_json().
|
static |
Handler for root RESTful resource.
Definition at line 169 of file res_ari.c.
Referenced by get_root_handler().
|
static |
Lock for root_handler