diff options
author | Benjamin Ford <bford@digium.com> | 2015-07-29 14:17:09 -0500 |
---|---|---|
committer | Benjamin Ford <bford@digium.com> | 2015-07-31 11:43:47 -0500 |
commit | 1ae762634c317fbcbd98a8c34d2474f7d4b654ed (patch) | |
tree | 84127e860a5d60a43d64d4a589546dfba157d323 /res/ari/ari_model_validators.c | |
parent | f78a4b52b8ed7b5b367c3465652a7ce98fe9175d (diff) |
ARI: Rotate log channels.
An http request can be sent to rotate a specified log channel.
If the channel does not exist, an error response will be
returned.
The command "curl -v -u user:pass -X PUT 'http://localhost:8088
/ari/asterisk/logging/logChannelName/rotate'" can be run in the
terminal to access this new functionality.
* Added the ability to rotate log files through ARI
ASTERISK-25252
Change-Id: Iaefa21cbbc1b29effb33004ee3d89c977e76ab01
Diffstat (limited to 'res/ari/ari_model_validators.c')
-rw-r--r-- | res/ari/ari_model_validators.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/res/ari/ari_model_validators.c b/res/ari/ari_model_validators.c index 667589601..120daf546 100644 --- a/res/ari/ari_model_validators.c +++ b/res/ari/ari_model_validators.c @@ -362,6 +362,61 @@ ari_validator ast_ari_validate_config_tuple_fn(void) return ast_ari_validate_config_tuple; } +int ast_ari_validate_log_channel(struct ast_json *json) +{ + int res = 1; + struct ast_json_iter *iter; + int has_logging_levels = 0; + int has_name = 0; + + for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) { + if (strcmp("logging_levels", ast_json_object_iter_key(iter)) == 0) { + int prop_is_valid; + has_logging_levels = 1; + prop_is_valid = ast_ari_validate_list( + ast_json_object_iter_value(iter), + ast_ari_validate_string); + if (!prop_is_valid) { + ast_log(LOG_ERROR, "ARI LogChannel field logging_levels failed validation\n"); + 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 + { + ast_log(LOG_ERROR, + "ARI LogChannel has undocumented field %s\n", + ast_json_object_iter_key(iter)); + res = 0; + } + } + + if (!has_logging_levels) { + ast_log(LOG_ERROR, "ARI LogChannel missing required field logging_levels\n"); + res = 0; + } + + if (!has_name) { + ast_log(LOG_ERROR, "ARI LogChannel missing required field name\n"); + res = 0; + } + + return res; +} + +ari_validator ast_ari_validate_log_channel_fn(void) +{ + return ast_ari_validate_log_channel; +} + int ast_ari_validate_module(struct ast_json *json) { int res = 1; |