Asterisk - The Open Source Telephony Project
18.5.0
|
Implementation Swagger validators. More...
#include "asterisk.h"
#include "ari/ari_model_validators.h"
#include "asterisk/logger.h"
#include "asterisk/module.h"
#include "asterisk/utils.h"
#include <regex.h>
Go to the source code of this file.
Macros | |
#define | ISO8601_PATTERN "^" REGEX_YMD "(T" REGEX_HMS REGEX_TZ ")?$" |
#define | REGEX_HMS "[0-2][0-9]:[0-5][0-9](:[0-6][0-9](.[0-9]+)?)?" |
#define | REGEX_TZ "(Z|[-+][0-2][0-9](:?[0-5][0-9])?)" |
#define | REGEX_YMD "[0-9]{4}-[01][0-9]-[0-3][0-9]" |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
int | ast_ari_validate_boolean (struct ast_json *json) |
Validator for native Swagger boolean. More... | |
int | ast_ari_validate_byte (struct ast_json *json) |
Validator for native Swagger byte. More... | |
int | ast_ari_validate_date (struct ast_json *json) |
Validator for native Swagger date. More... | |
int | ast_ari_validate_double (struct ast_json *json) |
Validator for native Swagger double. More... | |
int | ast_ari_validate_float (struct ast_json *json) |
Validator for native Swagger float. More... | |
int | ast_ari_validate_int (struct ast_json *json) |
Validator for native Swagger int. More... | |
int | ast_ari_validate_list (struct ast_json *json, int(*fn)(struct ast_json *)) |
Validator for a Swagger List[]/JSON array. More... | |
int | ast_ari_validate_long (struct ast_json *json) |
Validator for native Swagger long. More... | |
int | ast_ari_validate_object (struct ast_json *json) |
Validator for native Swagger object. More... | |
int | ast_ari_validate_string (struct ast_json *json) |
Validator for native Swagger string. More... | |
int | ast_ari_validate_void (struct ast_json *json) |
Validator for native Swagger void. More... | |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
static int | check_range (intmax_t minval, intmax_t maxval, struct ast_json *json) |
static int | check_type (struct ast_json *json, enum ast_json_type expected) |
static int | load_module (void) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER | AST_MODFLAG_GLOBAL_SYMBOLS , .description = "ARI Model validators" , .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, .load_pri = AST_MODPRI_APP_DEPEND, } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static regex_t | date_regex |
Implementation Swagger validators.
Definition in file res_ari_model.c.
Definition at line 53 of file res_ari_model.c.
Referenced by load_module().
#define REGEX_HMS "[0-2][0-9]:[0-5][0-9](:[0-6][0-9](.[0-9]+)?)?" |
Definition at line 47 of file res_ari_model.c.
#define REGEX_TZ "(Z|[-+][0-2][0-9](:?[0-5][0-9])?)" |
Definition at line 50 of file res_ari_model.c.
#define REGEX_YMD "[0-9]{4}-[01][0-9]-[0-3][0-9]" |
Definition at line 43 of file res_ari_model.c.
|
static |
Definition at line 209 of file res_ari_model.c.
|
static |
Definition at line 209 of file res_ari_model.c.
int ast_ari_validate_boolean | ( | struct ast_json * | json | ) |
Validator for native Swagger boolean.
json | JSON object to validate. |
Definition at line 107 of file res_ari_model.c.
References AST_JSON_FALSE, AST_JSON_TRUE, ast_json_typename(), ast_json_typeof(), ast_log, and LOG_ERROR.
Referenced by ast_ari_validate_bridge_attended_transfer(), ast_ari_validate_bridge_blind_transfer(), ast_ari_validate_channel_hangup_request(), and AST_TEST_DEFINE().
int ast_ari_validate_byte | ( | struct ast_json * | json | ) |
Validator for native Swagger byte.
json | JSON object to validate. |
Definition at line 101 of file res_ari_model.c.
References check_range().
Referenced by AST_TEST_DEFINE().
int ast_ari_validate_date | ( | struct ast_json * | json | ) |
Validator for native Swagger date.
json | JSON object to validate. |
Definition at line 148 of file res_ari_model.c.
References ast_assert, AST_JSON_STRING, ast_json_string_get(), ast_log, check_type(), date_regex, LOG_ERROR, NULL, and str.
Referenced by ast_ari_validate_application_move_failed(), ast_ari_validate_application_replaced(), ast_ari_validate_bridge(), ast_ari_validate_bridge_attended_transfer(), ast_ari_validate_bridge_blind_transfer(), ast_ari_validate_bridge_created(), ast_ari_validate_bridge_destroyed(), ast_ari_validate_bridge_merged(), ast_ari_validate_bridge_video_source_changed(), ast_ari_validate_channel(), ast_ari_validate_channel_caller_id(), ast_ari_validate_channel_connected_line(), ast_ari_validate_channel_created(), ast_ari_validate_channel_destroyed(), ast_ari_validate_channel_dialplan(), ast_ari_validate_channel_dtmf_received(), ast_ari_validate_channel_entered_bridge(), ast_ari_validate_channel_hangup_request(), ast_ari_validate_channel_hold(), ast_ari_validate_channel_left_bridge(), ast_ari_validate_channel_state_change(), ast_ari_validate_channel_talking_finished(), ast_ari_validate_channel_talking_started(), ast_ari_validate_channel_unhold(), ast_ari_validate_channel_userevent(), ast_ari_validate_channel_varset(), ast_ari_validate_contact_status_change(), ast_ari_validate_device_state_changed(), ast_ari_validate_dial(), ast_ari_validate_endpoint_state_change(), ast_ari_validate_event(), ast_ari_validate_peer_status_change(), ast_ari_validate_playback_continuing(), ast_ari_validate_playback_finished(), ast_ari_validate_playback_started(), ast_ari_validate_recording_failed(), ast_ari_validate_recording_finished(), ast_ari_validate_recording_started(), ast_ari_validate_stasis_end(), ast_ari_validate_stasis_start(), ast_ari_validate_status_info(), ast_ari_validate_text_message_received(), and AST_TEST_DEFINE().
int ast_ari_validate_double | ( | struct ast_json * | json | ) |
Validator for native Swagger double.
json | JSON object to validate. |
Definition at line 138 of file res_ari_model.c.
References AST_JSON_REAL, and check_type().
Referenced by ast_ari_validate_config_info(), and ast_ari_validate_rtpstat().
int ast_ari_validate_float | ( | struct ast_json * | json | ) |
Validator for native Swagger float.
json | JSON object to validate. |
Definition at line 133 of file res_ari_model.c.
References AST_JSON_REAL, and check_type().
int ast_ari_validate_int | ( | struct ast_json * | json | ) |
Validator for native Swagger int.
json | JSON object to validate. |
Definition at line 121 of file res_ari_model.c.
References check_range().
Referenced by ast_ari_validate_channel_caller_id(), ast_ari_validate_channel_destroyed(), ast_ari_validate_channel_dtmf_received(), ast_ari_validate_channel_hangup_request(), ast_ari_validate_channel_talking_finished(), ast_ari_validate_config_info(), ast_ari_validate_live_recording(), ast_ari_validate_mailbox(), ast_ari_validate_module(), ast_ari_validate_rtpstat(), AST_TEST_DEFINE(), and wrap_ast_ari_validate_int().
Validator for a Swagger List[]/JSON array.
json | JSON object to validate. |
fn | Validator to call on every element in the array. |
Definition at line 164 of file res_ari_model.c.
References AST_JSON_ARRAY, ast_json_array_get(), ast_json_array_size(), ast_log, check_type(), and LOG_ERROR.
Referenced by ast_ari_applications_list_cb(), ast_ari_asterisk_get_object_cb(), ast_ari_asterisk_list_log_channels_cb(), ast_ari_asterisk_list_modules_cb(), ast_ari_asterisk_update_object_cb(), ast_ari_bridges_list_cb(), ast_ari_channels_list_cb(), ast_ari_device_states_list_cb(), ast_ari_endpoints_list_by_tech_cb(), ast_ari_endpoints_list_cb(), ast_ari_mailboxes_list_cb(), ast_ari_recordings_list_stored_cb(), ast_ari_sounds_list_cb(), ast_ari_validate_application(), ast_ari_validate_application_move_failed(), ast_ari_validate_bridge(), ast_ari_validate_endpoint(), ast_ari_validate_missing_params(), ast_ari_validate_sound(), ast_ari_validate_stasis_start(), and AST_TEST_DEFINE().
int ast_ari_validate_long | ( | struct ast_json * | json | ) |
Validator for native Swagger long.
json | JSON object to validate. |
Definition at line 127 of file res_ari_model.c.
References AST_JSON_INTEGER, and check_type().
Referenced by ast_ari_validate_dialplan_cep(), and AST_TEST_DEFINE().
int ast_ari_validate_object | ( | struct ast_json * | json | ) |
Validator for native Swagger object.
json | JSON object to validate. |
Definition at line 96 of file res_ari_model.c.
References AST_JSON_OBJECT, and check_type().
Referenced by ast_ari_validate_application(), ast_ari_validate_channel(), ast_ari_validate_channel_userevent(), and ast_ari_validate_text_message().
int ast_ari_validate_string | ( | struct ast_json * | json | ) |
Validator for native Swagger string.
json | JSON object to validate. |
Definition at line 143 of file res_ari_model.c.
References AST_JSON_STRING, and check_type().
Referenced by ast_ari_validate_application(), ast_ari_validate_application_move_failed(), ast_ari_validate_application_replaced(), ast_ari_validate_asterisk_ping(), ast_ari_validate_bridge(), ast_ari_validate_bridge_attended_transfer(), ast_ari_validate_bridge_blind_transfer(), ast_ari_validate_bridge_created(), ast_ari_validate_bridge_destroyed(), ast_ari_validate_bridge_merged(), ast_ari_validate_bridge_video_source_changed(), ast_ari_validate_build_info(), ast_ari_validate_caller_id(), ast_ari_validate_channel(), ast_ari_validate_channel_caller_id(), ast_ari_validate_channel_connected_line(), ast_ari_validate_channel_created(), ast_ari_validate_channel_destroyed(), ast_ari_validate_channel_dialplan(), ast_ari_validate_channel_dtmf_received(), ast_ari_validate_channel_entered_bridge(), ast_ari_validate_channel_hangup_request(), ast_ari_validate_channel_hold(), ast_ari_validate_channel_left_bridge(), ast_ari_validate_channel_state_change(), ast_ari_validate_channel_talking_finished(), ast_ari_validate_channel_talking_started(), ast_ari_validate_channel_unhold(), ast_ari_validate_channel_userevent(), ast_ari_validate_channel_varset(), ast_ari_validate_config_info(), ast_ari_validate_config_tuple(), ast_ari_validate_contact_info(), ast_ari_validate_contact_status_change(), ast_ari_validate_device_state(), ast_ari_validate_device_state_changed(), ast_ari_validate_dial(), ast_ari_validate_dialplan_cep(), ast_ari_validate_endpoint(), ast_ari_validate_endpoint_state_change(), ast_ari_validate_event(), ast_ari_validate_format_lang_pair(), ast_ari_validate_live_recording(), ast_ari_validate_log_channel(), ast_ari_validate_mailbox(), ast_ari_validate_message(), ast_ari_validate_missing_params(), ast_ari_validate_module(), ast_ari_validate_peer(), ast_ari_validate_peer_status_change(), ast_ari_validate_playback(), ast_ari_validate_playback_continuing(), ast_ari_validate_playback_finished(), ast_ari_validate_playback_started(), ast_ari_validate_recording_failed(), ast_ari_validate_recording_finished(), ast_ari_validate_recording_started(), ast_ari_validate_rtpstat(), ast_ari_validate_set_id(), ast_ari_validate_sound(), ast_ari_validate_stasis_end(), ast_ari_validate_stasis_start(), ast_ari_validate_stored_recording(), ast_ari_validate_system_info(), ast_ari_validate_text_message(), ast_ari_validate_text_message_received(), ast_ari_validate_variable(), AST_TEST_DEFINE(), and wrap_ast_ari_validate_string().
int ast_ari_validate_void | ( | struct ast_json * | json | ) |
Validator for native Swagger void.
json | JSON object to validate. |
Definition at line 91 of file res_ari_model.c.
References AST_JSON_NULL, and check_type().
Referenced by ast_ari_asterisk_add_log_cb(), ast_ari_asterisk_delete_log_cb(), ast_ari_asterisk_delete_object_cb(), ast_ari_asterisk_load_module_cb(), ast_ari_asterisk_reload_module_cb(), ast_ari_asterisk_rotate_log_cb(), ast_ari_asterisk_set_global_var_cb(), ast_ari_asterisk_unload_module_cb(), ast_ari_bridges_add_channel_cb(), ast_ari_bridges_clear_video_source_cb(), ast_ari_bridges_destroy_cb(), ast_ari_bridges_remove_channel_cb(), ast_ari_bridges_set_video_source_cb(), ast_ari_bridges_start_moh_cb(), ast_ari_bridges_stop_moh_cb(), ast_ari_channels_answer_cb(), ast_ari_channels_continue_in_dialplan_cb(), ast_ari_channels_dial_cb(), ast_ari_channels_hangup_cb(), ast_ari_channels_hold_cb(), ast_ari_channels_move_cb(), ast_ari_channels_mute_cb(), ast_ari_channels_redirect_cb(), ast_ari_channels_ring_cb(), ast_ari_channels_ring_stop_cb(), ast_ari_channels_send_dtmf_cb(), ast_ari_channels_set_channel_var_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_cb(), ast_ari_device_states_delete_cb(), ast_ari_device_states_update_cb(), ast_ari_endpoints_send_message_cb(), ast_ari_endpoints_send_message_to_endpoint_cb(), ast_ari_events_user_event_cb(), ast_ari_mailboxes_delete_cb(), ast_ari_mailboxes_update_cb(), ast_ari_playbacks_control_cb(), ast_ari_playbacks_stop_cb(), ast_ari_recordings_cancel_cb(), ast_ari_recordings_delete_stored_cb(), ast_ari_recordings_mute_cb(), ast_ari_recordings_pause_cb(), ast_ari_recordings_stop_cb(), ast_ari_recordings_unmute_cb(), and ast_ari_recordings_unpause_cb().
struct ast_module* AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 209 of file res_ari_model.c.
|
static |
Definition at line 74 of file res_ari_model.c.
References AST_JSON_INTEGER, ast_json_integer_get(), ast_log, check_type(), and LOG_ERROR.
Referenced by ast_ari_validate_byte(), and ast_ari_validate_int().
|
static |
Definition at line 55 of file res_ari_model.c.
References ast_json_typename(), ast_json_typeof(), ast_log, and LOG_ERROR.
Referenced by ast_ari_validate_date(), ast_ari_validate_double(), ast_ari_validate_float(), ast_ari_validate_list(), ast_ari_validate_long(), ast_ari_validate_object(), ast_ari_validate_string(), ast_ari_validate_void(), and check_range().
|
static |
Definition at line 186 of file res_ari_model.c.
References AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, date_regex, and ISO8601_PATTERN.
Referenced by unload_module().
|
static |
Definition at line 198 of file res_ari_model.c.
References AST_MODFLAG_GLOBAL_SYMBOLS, AST_MODFLAG_LOAD_ORDER, AST_MODPRI_APP_DEPEND, AST_MODULE_INFO(), AST_MODULE_SUPPORT_CORE, ASTERISK_GPL_KEY, date_regex, and load_module().
|
static |
Definition at line 209 of file res_ari_model.c.
|
static |
Definition at line 209 of file res_ari_model.c.
|
static |
Definition at line 40 of file res_ari_model.c.
Referenced by ast_ari_validate_date(), load_module(), and unload_module().