ARI: Creating log channels

An http request can be sent to create a log channel
in Asterisk.

The command "curl -v -u user:pass -X POST
'http://localhost:088/ari/asterisk/logging/mylog?
configuration=notice,warning'" can be run in the terminal
to access the newly implemented functionality for ARI.

* Ability to create log channels using ARI

ASTERISK-25252

Change-Id: I9a20e5c75716dfbb6b62fd3474faf55be20bd782
This commit is contained in:
Scott Emidy
2015-08-07 11:14:06 -05:00
parent ecd4cde521
commit b91ca7ba49
8 changed files with 249 additions and 17 deletions

View File

@@ -366,12 +366,22 @@ int ast_ari_validate_log_channel(struct ast_json *json)
{
int res = 1;
struct ast_json_iter *iter;
int has_channel = 0;
int has_configuration = 0;
int has_name = 0;
int has_status = 0;
int has_type = 0;
for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
int prop_is_valid;
has_channel = 1;
prop_is_valid = ast_ari_validate_string(
ast_json_object_iter_value(iter));
if (!prop_is_valid) {
ast_log(LOG_ERROR, "ARI LogChannel field channel failed validation\n");
res = 0;
}
} else
if (strcmp("configuration", ast_json_object_iter_key(iter)) == 0) {
int prop_is_valid;
has_configuration = 1;
@@ -382,16 +392,6 @@ int ast_ari_validate_log_channel(struct ast_json *json)
res = 0;
}
} else
if (strcmp("name", ast_json_object_iter_key(iter)) == 0) {
int prop_is_valid;
has_name = 1;
prop_is_valid = ast_ari_validate_string(
ast_json_object_iter_value(iter));
if (!prop_is_valid) {
ast_log(LOG_ERROR, "ARI LogChannel field name failed validation\n");
res = 0;
}
} else
if (strcmp("status", ast_json_object_iter_key(iter)) == 0) {
int prop_is_valid;
has_status = 1;
@@ -420,13 +420,13 @@ int ast_ari_validate_log_channel(struct ast_json *json)
}
}
if (!has_configuration) {
ast_log(LOG_ERROR, "ARI LogChannel missing required field configuration\n");
if (!has_channel) {
ast_log(LOG_ERROR, "ARI LogChannel missing required field channel\n");
res = 0;
}
if (!has_name) {
ast_log(LOG_ERROR, "ARI LogChannel missing required field name\n");
if (!has_configuration) {
ast_log(LOG_ERROR, "ARI LogChannel missing required field configuration\n");
res = 0;
}