65 for (it_change_set = change_set; it_change_set; it_change_set = it_change_set->
next) {
69 "attribute", it_change_set->
name,
70 "value", it_change_set->
value);
101 response, 404,
"Not Found",
102 "configClass '%s' not found",
110 response, 404,
"Not Found",
111 "objectType '%s' not found",
119 response, 404,
"Not Found",
120 "Object with id '%s' not found",
140 response, 404,
"Not Found",
141 "configClass '%s' not found",
149 response, 404,
"Not Found",
150 "objectType '%s' not found",
157 ast_debug(5,
"Sorcery object '%s' does not exist; creating it\n", args->
id);
179 if (!fields && !created) {
182 response, 400,
"Bad request",
183 "Fields must be provided to update object '%s'",
216 response, 400,
"Bad request",
217 "%s of object '%s' failed field value validation",
218 created ?
"Creation" :
"Update",
228 response, 403,
"Forbidden",
229 "Cannot create sorcery objects of type '%s'",
236 response, 403,
"Forbidden",
237 "Cannot update sorcery objects of type '%s'",
258 response, 404,
"Not Found",
259 "configClass '%s' not found",
267 response, 404,
"Not Found",
268 "objectType '%s' not found",
276 response, 404,
"Not Found",
277 "Object with id '%s' not found",
284 response, 403,
"Forbidden",
285 "Could not delete object with id '%s'",
300 int show_build = show_all;
301 int show_system = show_all;
302 int show_config = show_all;
303 int show_status = show_all;
308 if (strcasecmp(
"build", args->
only[i]) == 0) {
310 }
else if (strcasecmp(
"system", args->
only[i]) == 0) {
312 }
else if (strcasecmp(
"config", args->
only[i]) == 0) {
314 }
else if (strcasecmp(
"status", args->
only[i]) == 0) {
327 "{ s: s, s: s, s: s," 328 " s: s, s: s, s: s }",
347 "entity_id", eid_str));
353 " s: { s: s, s: s } }",
411 const char *
status,
const char *like,
416 module_info =
ast_json_pack(
"{s: s, s: s, s: i, s: s, s: s}",
418 "description", description,
460 const char *
status,
const char *like,
462 const char *condition)
464 int json_obj_set = 0;
466 if (strcmp(condition, module) != 0) {
477 if (json_obj_set != 0) {
489 int module_retrieved = 0;
495 response, 404,
"Not Found",
496 "Module could not be found in running modules");
508 if (!module_retrieved) {
510 response, 409,
"Conflict",
511 "Module information could not be retrieved");
529 response, 409,
"Conflict",
530 "Module is already loaded");
538 response, 409,
"Conflict",
539 "Module load declined");
543 response, 409,
"Conflict",
544 "Module was skipped");
548 response, 409,
"Conflict",
549 "Module could not be loaded properly");
567 response, 404,
"Not Found",
568 "Module not found in running modules");
574 if (unload_result != 0) {
576 response, 409,
"Conflict",
577 "Module could not be unloaded");
594 response, 404,
"Not Found",
595 "Module not found in running modules");
603 response, 404,
"Not Found",
604 "Module could not be found");
608 response, 409,
"Conflict",
609 "An unknown error occurred while reloading the module");
613 response, 409,
"Conflict",
614 "Another reload is currently in progress");
618 response, 409,
"Conflict",
619 "Module has not been initialized");
623 response, 409,
"Conflict",
624 "Module does not support reloading");
664 const char *
status,
const char *configuration,
void *log_data_list)
669 "channel", channel,
"type", type,
"status", status,
"configuration",
692 "Response body is not valid");
697 "Allocation Failed");
717 "Configuration levels are required");
721 "Log channel already exists");
725 "Allocation failed");
744 response, 404,
"Not Found",
745 "Log channel does not exist");
749 response, 500,
"Internal Server Error",
750 "Allocation failed");
769 "Log channel does not exist");
773 "Allocation failed");
793 response, 400,
"Bad Request",
794 "Variable name is required");
822 response, 400,
"Bad Request",
823 "Variable name is required");
struct ast_variable * next
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
int ast_update_module_list_data(int(*modentry)(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 *like, void *data)
Ask for a list of modules, descriptions, use counts and status.
Asterisk main include file. File version handling, generic pbx functions.
const char * ast_build_user
const char * config_class
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
enum ast_module_load_result ast_load_resource(const char *resource_name)
Load a 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.
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Asterisk version information.
char * ast_eid_to_str(char *s, int maxlen, struct ast_eid *eid)
Convert an EID to a string.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
const char * ast_get_version(void)
Retrieve the Asterisk version string.
int ast_logger_get_channels(int(*logentry)(const char *channel, const char *type, const char *status, const char *configuration, void *data), void *data)
Retrieve the existing log channels.
enum ast_module_reload_result ast_module_reload(const char *name)
Reload asterisk modules.
ast_module_reload_result
Possible return types for ast_module_reload.
const char * ast_module_support_level_to_string(enum ast_module_support_level support_level)
int ast_update_module_list_condition(int(*modentry)(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), const char *like, void *data, const char *condition)
Ask for a list of modules, descriptions, use counts and status.
int ast_logger_rotate_channel(const char *log_channel)
Rotate the specified log channel.
const char * ast_build_date
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.
const char * ast_build_os
Full structure for sorcery.
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.
int ast_sorcery_objectset_apply(const struct ast_sorcery *sorcery, void *object, struct ast_variable *objectset)
Apply an object set (KVP list) to an object.
static int copy(char *infile, char *outfile)
Utility function to copy a file.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
double ast_option_maxload
const char * ast_config_AST_RUN_USER
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.
static int process_module_list(const char *module, const char *description, int usecnt, const char *status, const char *like, enum ast_module_support_level support_level, void *module_data_list)
Process module information and append to a json array.
static void return_sorcery_object(struct ast_sorcery *sorcery, void *sorcery_obj, struct ast_ari_response *response)
void ast_ari_response_alloc_failed(struct ast_ari_response *response)
Fill in response with a 500 message for allocation failures.
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_module_check(const char *name)
Check if module with the name given is loaded.
int ast_json_object_set(struct ast_json *object, const char *key, struct ast_json *value)
Set a field in a JSON object.
const char * ast_build_kernel
#define ast_strlen_zero(foo)
void * ast_sorcery_retrieve_by_id(const struct ast_sorcery *sorcery, const char *type, const char *id)
Retrieve an object using its unique identifier.
#define ast_sorcery_unref(sorcery)
Decrease the reference count of a sorcery structure.
const char * ast_config_AST_SYSTEM_NAME
const char * ast_config_AST_RUN_GROUP
const char * ast_build_machine
#define ast_debug(level,...)
Log a DEBUG message.
int ast_sorcery_create(const struct ast_sorcery *sorcery, void *object)
Create and potentially persist an object using an available wizard.
Structure for registered object type.
Asterisk file paths, configured in asterisk.conf.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
struct ast_json * ast_json_string_create(const char *value)
Construct a JSON string from value.
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.
char ast_defaultlanguage[]
void ast_ari_response_ok(struct ast_ari_response *response, struct ast_json *message)
Fill in an OK (200) ast_ari_response.
#define ao2_ref(o, delta)
struct timeval ast_lastreloadtime
static int process_log_list(const char *channel, const char *type, const char *status, const char *configuration, void *log_data_list)
Process logger information and append to a json array.
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_variable_new(name, value, filename)
const char * log_channel_name
int ast_logger_create_channel(const char *log_channel, const char *components)
Create a log channel.
Core PBX routines and definitions.
struct ast_json * ast_json_array_create(void)
Create a empty JSON array.
struct ast_json * ast_json_timeval(const struct timeval tv, const char *zone)
Construct a timeval as JSON.
struct ast_sorcery_object_type * ast_sorcery_get_object_type(const struct ast_sorcery *sorcery, const char *type)
Get the sorcery object type given a type name.
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.
int ast_json_array_append(struct ast_json *array, struct ast_json *value)
Append to an array.
const char * configuration
const char * log_channel_name
int ast_sorcery_delete(const struct ast_sorcery *sorcery, void *object)
Delete an object.
void ast_ari_asterisk_ping(struct ast_variable *headers, struct ast_ari_asterisk_ping_args *args, struct ast_ari_response *response)
Response pong message.
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
void ast_ari_response_accepted(struct ast_ari_response *response)
Fill in a Accepted (202) ast_ari_response.
int ast_unload_resource(const char *resource_name, enum ast_module_unload_mode)
Unload a module.
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.
void * ast_sorcery_alloc(const struct ast_sorcery *sorcery, const char *type, const char *id)
Allocate an object.
#define ast_sorcery_objectset_create(sorcery, object)
Create an object set (KVP list) for an object.
int ast_logger_remove_channel(const char *log_channel)
Delete the specified log channel.
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.
Module could not be loaded properly.
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_response_no_content(struct ast_ari_response *response)
Fill in a No Content (204) ast_ari_response.
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.
Support for logging to various files, console and syslog Configuration in file logger.conf.
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.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
struct ast_eid ast_eid_default
Global EID.
struct timeval ast_startuptime
struct ast_json * ast_json_object_create(void)
Create a new JSON object.
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.
const char * ast_str_retrieve_variable(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, struct varshead *headp, const char *var)
static struct ast_sorcery * sorcery
struct ast_json * ast_json_real_create(double value)
Create a JSON real number.
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
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
void * ast_sorcery_copy(const struct ast_sorcery *sorcery, const void *object)
Create a copy of an object.
size_t ast_json_array_size(const struct ast_json *array)
Get the size of a JSON array.
Abstract JSON element (object, array, string, int, ...).
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
const char * config_class
Asterisk module definitions.
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)
Identify module by name and process resource information.
struct ast_json * ast_json_array_get(const struct ast_json *array, size_t index)
Get an element from an array.
#define ast_variable_list_append(head, new_var)
struct ast_sorcery * ast_sorcery_retrieve_by_module_name(const char *module)
Retrieves an existing sorcery instance by module name.
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.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Sorcery Data Access Layer API.
int ast_sorcery_update(const struct ast_sorcery *sorcery, void *object)
Update an object.
struct ast_json * ast_json_integer_create(intmax_t value)
Create a JSON integer.