summaryrefslogtreecommitdiff
path: root/res/ari/ari_model_validators.c
diff options
context:
space:
mode:
authorBenjamin Ford <bford@digium.com>2015-07-29 14:17:09 -0500
committerBenjamin Keith Ford <bford@digium.com>2015-07-31 11:46:08 -0500
commit1f02d20da41ef79e913317795e44dbc6a34464f9 (patch)
tree1dad3d3a1e9c9cf3bcdddd8136aeb1ed23e194f8 /res/ari/ari_model_validators.c
parentd61ea4bcc28a9504d44534f435be1515d713a496 (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.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/res/ari/ari_model_validators.c b/res/ari/ari_model_validators.c
index fa16aea20..1be32de3d 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;