47 #if defined(AST_DEVMODE)
69 #if defined(AST_DEVMODE)
74 for (i = path_vars; i; i = i->
next) {
75 if (strcmp(i->
name,
"configClass") == 0) {
78 if (strcmp(i->
name,
"objectType") == 0) {
81 if (strcmp(i->
name,
"id") == 0) {
87 #if defined(AST_DEVMODE)
92 is_valid = response->
message == NULL;
100 if (200 <= code && code <= 299) {
104 ast_log(LOG_ERROR,
"Invalid error response %d for /asterisk/config/dynamic/{configClass}/{objectType}/{id}\n", code);
110 ast_log(LOG_ERROR,
"Response validation failed for /asterisk/config/dynamic/{configClass}/{objectType}/{id}\n");
112 "Internal Server Error",
"Response validation failed");
116 fin: __attribute__((unused))
143 #if defined(AST_DEVMODE)
148 for (i = path_vars; i; i = i->
next) {
149 if (strcmp(i->
name,
"configClass") == 0) {
152 if (strcmp(i->
name,
"objectType") == 0) {
155 if (strcmp(i->
name,
"id") == 0) {
162 #if defined(AST_DEVMODE)
167 is_valid = response->
message == NULL;
177 if (200 <= code && code <= 299) {
181 ast_log(LOG_ERROR,
"Invalid error response %d for /asterisk/config/dynamic/{configClass}/{objectType}/{id}\n", code);
187 ast_log(LOG_ERROR,
"Response validation failed for /asterisk/config/dynamic/{configClass}/{objectType}/{id}\n");
189 "Internal Server Error",
"Response validation failed");
193 fin: __attribute__((unused))
212 #if defined(AST_DEVMODE)
217 for (i = path_vars; i; i = i->
next) {
218 if (strcmp(i->
name,
"configClass") == 0) {
221 if (strcmp(i->
name,
"objectType") == 0) {
224 if (strcmp(i->
name,
"id") == 0) {
230 #if defined(AST_DEVMODE)
235 is_valid = response->
message == NULL;
244 if (200 <= code && code <= 299) {
248 ast_log(LOG_ERROR,
"Invalid error response %d for /asterisk/config/dynamic/{configClass}/{objectType}/{id}\n", code);
254 ast_log(LOG_ERROR,
"Response validation failed for /asterisk/config/dynamic/{configClass}/{objectType}/{id}\n");
256 "Internal Server Error",
"Response validation failed");
260 fin: __attribute__((unused))
274 ast_free(args->
only);
317 #if defined(AST_DEVMODE)
322 for (i = get_params; i; i = i->
next) {
323 if (strcmp(i->
name,
"only") == 0) {
325 char *vals[MAX_VALS];
352 "Too many values for only");
363 args.
only[j] = (vals[j]);
373 #if defined(AST_DEVMODE)
378 is_valid = response->
message == NULL;
385 if (200 <= code && code <= 299) {
389 ast_log(LOG_ERROR,
"Invalid error response %d for /asterisk/info\n", code);
395 ast_log(LOG_ERROR,
"Response validation failed for /asterisk/info\n");
397 "Internal Server Error",
"Response validation failed");
401 fin: __attribute__((unused))
421 #if defined(AST_DEVMODE)
427 #if defined(AST_DEVMODE)
432 is_valid = response->
message == NULL;
439 if (200 <= code && code <= 299) {
443 ast_log(LOG_ERROR,
"Invalid error response %d for /asterisk/ping\n", code);
449 ast_log(LOG_ERROR,
"Response validation failed for /asterisk/ping\n");
451 "Internal Server Error",
"Response validation failed");
455 fin: __attribute__((unused))
473 #if defined(AST_DEVMODE)
479 #if defined(AST_DEVMODE)
484 is_valid = response->
message == NULL;
491 if (200 <= code && code <= 299) {
495 ast_log(LOG_ERROR,
"Invalid error response %d for /asterisk/modules\n", code);
501 ast_log(LOG_ERROR,
"Response validation failed for /asterisk/modules\n");
503 "Internal Server Error",
"Response validation failed");
507 fin: __attribute__((unused))
526 #if defined(AST_DEVMODE)
531 for (i = path_vars; i; i = i->
next) {
532 if (strcmp(i->
name,
"moduleName") == 0) {
538 #if defined(AST_DEVMODE)
543 is_valid = response->
message == NULL;
552 if (200 <= code && code <= 299) {
556 ast_log(LOG_ERROR,
"Invalid error response %d for /asterisk/modules/{moduleName}\n", code);
562 ast_log(LOG_ERROR,
"Response validation failed for /asterisk/modules/{moduleName}\n");
564 "Internal Server Error",
"Response validation failed");
568 fin: __attribute__((unused))
587 #if defined(AST_DEVMODE)
592 for (i = path_vars; i; i = i->
next) {
593 if (strcmp(i->
name,
"moduleName") == 0) {
599 #if defined(AST_DEVMODE)
604 is_valid = response->
message == NULL;
612 if (200 <= code && code <= 299) {
616 ast_log(LOG_ERROR,
"Invalid error response %d for /asterisk/modules/{moduleName}\n", code);
622 ast_log(LOG_ERROR,
"Response validation failed for /asterisk/modules/{moduleName}\n");
624 "Internal Server Error",
"Response validation failed");
628 fin: __attribute__((unused))
647 #if defined(AST_DEVMODE)
652 for (i = path_vars; i; i = i->
next) {
653 if (strcmp(i->
name,
"moduleName") == 0) {
659 #if defined(AST_DEVMODE)
664 is_valid = response->
message == NULL;
673 if (200 <= code && code <= 299) {
677 ast_log(LOG_ERROR,
"Invalid error response %d for /asterisk/modules/{moduleName}\n", code);
683 ast_log(LOG_ERROR,
"Response validation failed for /asterisk/modules/{moduleName}\n");
685 "Internal Server Error",
"Response validation failed");
689 fin: __attribute__((unused))
708 #if defined(AST_DEVMODE)
713 for (i = path_vars; i; i = i->
next) {
714 if (strcmp(i->
name,
"moduleName") == 0) {
720 #if defined(AST_DEVMODE)
725 is_valid = response->
message == NULL;
734 if (200 <= code && code <= 299) {
738 ast_log(LOG_ERROR,
"Invalid error response %d for /asterisk/modules/{moduleName}\n", code);
744 ast_log(LOG_ERROR,
"Response validation failed for /asterisk/modules/{moduleName}\n");
746 "Internal Server Error",
"Response validation failed");
750 fin: __attribute__((unused))
768 #if defined(AST_DEVMODE)
774 #if defined(AST_DEVMODE)
779 is_valid = response->
message == NULL;
786 if (200 <= code && code <= 299) {
790 ast_log(LOG_ERROR,
"Invalid error response %d for /asterisk/logging\n", code);
796 ast_log(LOG_ERROR,
"Response validation failed for /asterisk/logging\n");
798 "Internal Server Error",
"Response validation failed");
802 fin: __attribute__((unused))
834 #if defined(AST_DEVMODE)
839 for (i = get_params; i; i = i->
next) {
840 if (strcmp(i->
name,
"configuration") == 0) {
845 for (i = path_vars; i; i = i->
next) {
846 if (strcmp(i->
name,
"logChannelName") == 0) {
856 #if defined(AST_DEVMODE)
861 is_valid = response->
message == NULL;
870 if (200 <= code && code <= 299) {
874 ast_log(LOG_ERROR,
"Invalid error response %d for /asterisk/logging/{logChannelName}\n", code);
880 ast_log(LOG_ERROR,
"Response validation failed for /asterisk/logging/{logChannelName}\n");
882 "Internal Server Error",
"Response validation failed");
886 fin: __attribute__((unused))
905 #if defined(AST_DEVMODE)
910 for (i = path_vars; i; i = i->
next) {
911 if (strcmp(i->
name,
"logChannelName") == 0) {
917 #if defined(AST_DEVMODE)
922 is_valid = response->
message == NULL;
930 if (200 <= code && code <= 299) {
934 ast_log(LOG_ERROR,
"Invalid error response %d for /asterisk/logging/{logChannelName}\n", code);
940 ast_log(LOG_ERROR,
"Response validation failed for /asterisk/logging/{logChannelName}\n");
942 "Internal Server Error",
"Response validation failed");
946 fin: __attribute__((unused))
965 #if defined(AST_DEVMODE)
970 for (i = path_vars; i; i = i->
next) {
971 if (strcmp(i->
name,
"logChannelName") == 0) {
977 #if defined(AST_DEVMODE)
982 is_valid = response->
message == NULL;
990 if (200 <= code && code <= 299) {
994 ast_log(LOG_ERROR,
"Invalid error response %d for /asterisk/logging/{logChannelName}/rotate\n", code);
1000 ast_log(LOG_ERROR,
"Response validation failed for /asterisk/logging/{logChannelName}/rotate\n");
1002 "Internal Server Error",
"Response validation failed");
1006 fin: __attribute__((unused))
1038 #if defined(AST_DEVMODE)
1043 for (i = get_params; i; i = i->
next) {
1044 if (strcmp(i->
name,
"variable") == 0) {
1054 #if defined(AST_DEVMODE)
1059 is_valid = response->
message == NULL;
1067 if (200 <= code && code <= 299) {
1071 ast_log(LOG_ERROR,
"Invalid error response %d for /asterisk/variable\n", code);
1077 ast_log(LOG_ERROR,
"Response validation failed for /asterisk/variable\n");
1079 "Internal Server Error",
"Response validation failed");
1083 fin: __attribute__((unused))
1119 #if defined(AST_DEVMODE)
1124 for (i = get_params; i; i = i->
next) {
1125 if (strcmp(i->
name,
"variable") == 0) {
1128 if (strcmp(i->
name,
"value") == 0) {
1138 #if defined(AST_DEVMODE)
1143 is_valid = response->
message == NULL;
1151 if (200 <= code && code <= 299) {
1155 ast_log(LOG_ERROR,
"Invalid error response %d for /asterisk/variable\n", code);
1161 ast_log(LOG_ERROR,
"Response validation failed for /asterisk/variable\n");
1163 "Internal Server Error",
"Response validation failed");
1167 fin: __attribute__((unused))
1305 static int unload_module(
void)
1311 static int load_module(
void)
1325 AST_MODULE_INFO(
ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT,
"RESTful API module - Asterisk resources",
1326 .support_level = AST_MODULE_SUPPORT_CORE,
1327 .load = load_module,
1328 .unload = unload_module,
1329 .requires =
"res_ari,res_ari_model,res_stasis",
struct ast_variable * next
int ast_ari_validate_variable(struct ast_json *json)
Validator for Variable.
static struct stasis_rest_handlers asterisk_modules_moduleName
REST handler for /api-docs/asterisk.json.
Asterisk main include file. File version handling, generic pbx functions.
static void ast_ari_asterisk_list_modules_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /asterisk/modules.
static void ast_ari_asterisk_get_info_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /asterisk/info.
static void ast_ari_asterisk_delete_log_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /asterisk/logging/{logChannelName}.
const char * config_class
static void ast_ari_asterisk_get_global_var_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /asterisk/variable.
static struct stasis_rest_handlers asterisk
REST handler for /api-docs/asterisk.json.
ari_validator ast_ari_validate_module_fn(void)
Function pointer to ast_ari_validate_module().
void ast_ari_asterisk_get_info(struct ast_variable *headers, struct ast_ari_asterisk_get_info_args *args, struct ast_ari_response *response)
Gets Asterisk system information.
void ast_ari_asterisk_delete_log(struct ast_variable *headers, struct ast_ari_asterisk_delete_log_args *args, struct ast_ari_response *response)
Deletes a log channel.
ari_validator ast_ari_validate_config_tuple_fn(void)
Function pointer to ast_ari_validate_config_tuple().
int ast_ari_asterisk_get_global_var_parse_body(struct ast_json *body, struct ast_ari_asterisk_get_global_var_args *args)
Body parsing function for /asterisk/variable.
static void ast_ari_asterisk_get_module_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /asterisk/modules/{moduleName}.
static void ast_ari_asterisk_load_module_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /asterisk/modules/{moduleName}.
static struct stasis_rest_handlers asterisk_config_dynamic
REST handler for /api-docs/asterisk.json.
int ast_ari_validate_asterisk_ping(struct ast_json *json)
Validator for AsteriskPing.
int ast_ari_asterisk_update_object_parse_body(struct ast_json *body, struct ast_ari_asterisk_update_object_args *args)
Body parsing function for /asterisk/config/dynamic/{configClass}/{objectType}/{id}.
Structure for variables, used for configurations and for channel variables.
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)
Get the value of a global variable.
static void ast_ari_asterisk_delete_object_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /asterisk/config/dynamic/{configClass}/{objectType}/{id}.
void ast_ari_asterisk_list_modules(struct ast_variable *headers, struct ast_ari_asterisk_list_modules_args *args, struct ast_ari_response *response)
List Asterisk modules.
static void ast_ari_asterisk_rotate_log_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /asterisk/logging/{logChannelName}/rotate.
Generated file - Build validators for ARI model objects.
#define ast_strdup(str)
A wrapper for strdup()
void ast_ari_asterisk_load_module(struct ast_variable *headers, struct ast_ari_asterisk_load_module_args *args, struct ast_ari_response *response)
Load an Asterisk module.
void ast_ari_response_alloc_failed(struct ast_ari_response *response)
Fill in response with a 500 message for allocation failures.
int ast_ari_asterisk_add_log_parse_body(struct ast_json *body, struct ast_ari_asterisk_add_log_args *args)
Body parsing function for /asterisk/logging/{logChannelName}.
void ast_ari_asterisk_get_module(struct ast_variable *headers, struct ast_ari_asterisk_get_module_args *args, struct ast_ari_response *response)
Get Asterisk module information.
int ast_ari_validate_void(struct ast_json *json)
Validator for native Swagger void.
static struct stasis_rest_handlers asterisk_config
REST handler for /api-docs/asterisk.json.
static struct stasis_rest_handlers asterisk_config_dynamic_configClass_objectType
REST handler for /api-docs/asterisk.json.
static struct stasis_rest_handlers asterisk_config_dynamic_configClass
REST handler for /api-docs/asterisk.json.
void ast_ari_asterisk_unload_module(struct ast_variable *headers, struct ast_ari_asterisk_unload_module_args *args, struct ast_ari_response *response)
Unload an Asterisk module.
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
Generated file - declares stubs to be implemented in res/ari/resource_asterisk.c. ...
#define ast_malloc(len)
A wrapper for malloc()
static void ast_ari_asterisk_ping_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /asterisk/ping.
const char * log_channel_name
static void ast_ari_asterisk_reload_module_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /asterisk/modules/{moduleName}.
describes a server instance
void ast_ari_asterisk_reload_module(struct ast_variable *headers, struct ast_ari_asterisk_reload_module_args *args, struct ast_ari_response *response)
Reload an Asterisk module.
const char * configuration
static struct stasis_rest_handlers asterisk_modules
REST handler for /api-docs/asterisk.json.
const char * log_channel_name
int ast_ari_add_handler(struct stasis_rest_handlers *handler)
void ast_ari_asterisk_ping(struct ast_variable *headers, struct ast_ari_asterisk_ping_args *args, struct ast_ari_response *response)
Response pong message.
ari_validator ast_ari_validate_log_channel_fn(void)
Function pointer to ast_ari_validate_log_channel().
static void ast_ari_asterisk_add_log_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /asterisk/logging/{logChannelName}.
void ast_ari_asterisk_delete_object(struct ast_variable *headers, struct ast_ari_asterisk_delete_object_args *args, struct ast_ari_response *response)
Delete a dynamic configuration object.
int ast_ari_remove_handler(struct stasis_rest_handlers *handler)
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.
static struct stasis_rest_handlers asterisk_variable
REST handler for /api-docs/asterisk.json.
enum ast_json_type ast_json_typeof(const struct ast_json *value)
Get the type of value.
Module has failed to load, may be in an inconsistent state.
void ast_ari_asterisk_add_log(struct ast_variable *headers, struct ast_ari_asterisk_add_log_args *args, struct ast_ari_response *response)
Adds a log channel.
void ast_ari_asterisk_list_log_channels(struct ast_variable *headers, struct ast_ari_asterisk_list_log_channels_args *args, struct ast_ari_response *response)
Gets Asterisk log channel information.
struct ast_json * message
static void ast_ari_asterisk_update_object_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /asterisk/config/dynamic/{configClass}/{objectType}/{id}.
void ast_ari_asterisk_rotate_log(struct ast_variable *headers, struct ast_ari_asterisk_rotate_log_args *args, struct ast_ari_response *response)
Rotates a log channel.
static struct stasis_rest_handlers asterisk_logging
REST handler for /api-docs/asterisk.json.
static struct stasis_rest_handlers asterisk_info
REST handler for /api-docs/asterisk.json.
const char * path_segment
int ast_ari_validate_asterisk_info(struct ast_json *json)
Validator for AsteriskInfo.
static void ast_ari_asterisk_list_log_channels_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /asterisk/logging.
static struct stasis_rest_handlers asterisk_logging_logChannelName
REST handler for /api-docs/asterisk.json.
static struct stasis_rest_handlers asterisk_logging_logChannelName_rotate
REST handler for /api-docs/asterisk.json.
void ast_ari_asterisk_get_object(struct ast_variable *headers, struct ast_ari_asterisk_get_object_args *args, struct ast_ari_response *response)
Retrieve a dynamic configuration object.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
const char * config_class
static struct stasis_rest_handlers asterisk_config_dynamic_configClass_objectType_id
REST handler for /api-docs/asterisk.json.
size_t ast_json_array_size(const struct ast_json *array)
Get the size of a JSON array.
static struct stasis_rest_handlers asterisk_ping
REST handler for /api-docs/asterisk.json.
Abstract JSON element (object, array, string, int, ...).
int ast_ari_validate_module(struct ast_json *json)
Validator for Module.
static void ast_ari_asterisk_get_object_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /asterisk/config/dynamic/{configClass}/{objectType}/{id}.
Stasis Application API. See Stasis Application API for detailed documentation.
void ast_ari_asterisk_update_object(struct ast_variable *headers, struct ast_ari_asterisk_update_object_args *args, struct ast_ari_response *response)
Create or update a dynamic configuration object.
const char * log_channel_name
int ast_ari_validate_list(struct ast_json *json, int(*fn)(struct ast_json *))
Validator for a Swagger List[]/JSON array.
static void ast_ari_asterisk_unload_module_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /asterisk/modules/{moduleName}.
int ast_ari_asterisk_set_global_var_parse_body(struct ast_json *body, struct ast_ari_asterisk_set_global_var_args *args)
Body parsing function for /asterisk/variable.
static void ast_ari_asterisk_set_global_var_cb(struct ast_tcptls_session_instance *ser, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Parameter parsing callback for /asterisk/variable.
#define ASTERISK_GPL_KEY
The text the key() function should return.
const char * config_class
Asterisk module definitions.
int ast_ari_asterisk_get_info_parse_body(struct ast_json *body, struct ast_ari_asterisk_get_info_args *args)
Body parsing function for /asterisk/info.
struct ast_json * ast_json_array_get(const struct ast_json *array, size_t index)
Get an element from an array.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
Handler for a single RESTful path segment.
void ast_ari_asterisk_set_global_var(struct ast_variable *headers, struct ast_ari_asterisk_set_global_var_args *args, struct ast_ari_response *response)
Set the value of a global variable.