diff options
author | David M. Lee <dlee@digium.com> | 2013-07-10 13:50:48 +0000 |
---|---|---|
committer | David M. Lee <dlee@digium.com> | 2013-07-10 13:50:48 +0000 |
commit | a73394abb874221ab3ae23348b285b217c1ee120 (patch) | |
tree | 179d7d699e3f838dfd05b14452a48f049b844a65 /res/stasis_http | |
parent | 0bfe2d4cc4dda5a4bcde039614336c104a88f8d3 (diff) |
Corrected api-docs for channel variables
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@393968 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/stasis_http')
-rw-r--r-- | res/stasis_http/ari_model_validators.c | 38 | ||||
-rw-r--r-- | res/stasis_http/ari_model_validators.h | 20 |
2 files changed, 58 insertions, 0 deletions
diff --git a/res/stasis_http/ari_model_validators.c b/res/stasis_http/ari_model_validators.c index 14b5d6974..bf3c0e7d0 100644 --- a/res/stasis_http/ari_model_validators.c +++ b/res/stasis_http/ari_model_validators.c @@ -57,6 +57,44 @@ ari_validator ari_validate_asterisk_info_fn(void) return ari_validate_asterisk_info; } +int ari_validate_variable(struct ast_json *json) +{ + int res = 1; + struct ast_json_iter *iter; + int has_value = 0; + + for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) { + if (strcmp("value", ast_json_object_iter_key(iter)) == 0) { + int prop_is_valid; + has_value = 1; + prop_is_valid = ari_validate_string( + ast_json_object_iter_value(iter)); + if (!prop_is_valid) { + ast_log(LOG_ERROR, "ARI Variable field value failed validation\n"); + res = 0; + } + } else + { + ast_log(LOG_ERROR, + "ARI Variable has undocumented field %s\n", + ast_json_object_iter_key(iter)); + res = 0; + } + } + + if (!has_value) { + ast_log(LOG_ERROR, "ARI Variable missing required field value\n"); + res = 0; + } + + return res; +} + +ari_validator ari_validate_variable_fn(void) +{ + return ari_validate_variable; +} + int ari_validate_endpoint(struct ast_json *json) { int res = 1; diff --git a/res/stasis_http/ari_model_validators.h b/res/stasis_http/ari_model_validators.h index ee3d09308..2f6418657 100644 --- a/res/stasis_http/ari_model_validators.h +++ b/res/stasis_http/ari_model_validators.h @@ -162,6 +162,24 @@ int ari_validate_asterisk_info(struct ast_json *json); ari_validator ari_validate_asterisk_info_fn(void); /*! + * \brief Validator for Variable. + * + * The value of a channel variable + * + * \param json JSON object to validate. + * \returns True (non-zero) if valid. + * \returns False (zero) if invalid. + */ +int ari_validate_variable(struct ast_json *json); + +/*! + * \brief Function pointer to ari_validate_variable(). + * + * See \ref ari_model_validators.h for more details. + */ +ari_validator ari_validate_variable_fn(void); + +/*! * \brief Validator for Endpoint. * * An external device that may offer/accept calls to/from Asterisk. @@ -767,6 +785,8 @@ ari_validator ari_validate_stasis_start_fn(void); * JSON models * * AsteriskInfo + * Variable + * - value: string (required) * Endpoint * - channel_ids: List[string] (required) * - resource: string (required) |