diff options
author | Jonathan Rose <jrose@digium.com> | 2013-12-17 23:25:49 +0000 |
---|---|---|
committer | Jonathan Rose <jrose@digium.com> | 2013-12-17 23:25:49 +0000 |
commit | b0bb03e916da4b4a37aa65b694e3aa1cecee8648 (patch) | |
tree | 697d4ba1137ca3b28fc79d1c976b2e342274c1fe /res/ari | |
parent | 91d0f305061a6111d9996750c04d54daa67b67bb (diff) |
bridging: Give bridges a name and a known creator
Bridges have two new optional properties, a creator and a name.
Certain consumers of bridges will automatically provide bridges that
they create with these properties. Examples include app_bridgewait,
res_parking, app_confbridge, and app_agent_pool. In addition, a name
may now be provided as an argument to the POST function for creating
new bridges via ARI.
(closes issue AFS-47)
Review: https://reviewboard.asterisk.org/r/3070/
........
Merged revisions 404042 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@404043 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/ari')
-rw-r--r-- | res/ari/ari_model_validators.c | 32 | ||||
-rw-r--r-- | res/ari/ari_model_validators.h | 2 | ||||
-rw-r--r-- | res/ari/resource_bridges.c | 2 | ||||
-rw-r--r-- | res/ari/resource_bridges.h | 2 |
4 files changed, 37 insertions, 1 deletions
diff --git a/res/ari/ari_model_validators.c b/res/ari/ari_model_validators.c index d99240bd8..a04818045 100644 --- a/res/ari/ari_model_validators.c +++ b/res/ari/ari_model_validators.c @@ -891,7 +891,9 @@ int ast_ari_validate_bridge(struct ast_json *json) int has_bridge_class = 0; int has_bridge_type = 0; int has_channels = 0; + int has_creator = 0; int has_id = 0; + int has_name = 0; int has_technology = 0; for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) { @@ -926,6 +928,16 @@ int ast_ari_validate_bridge(struct ast_json *json) res = 0; } } else + if (strcmp("creator", ast_json_object_iter_key(iter)) == 0) { + int prop_is_valid; + has_creator = 1; + prop_is_valid = ast_ari_validate_string( + ast_json_object_iter_value(iter)); + if (!prop_is_valid) { + ast_log(LOG_ERROR, "ARI Bridge field creator failed validation\n"); + res = 0; + } + } else if (strcmp("id", ast_json_object_iter_key(iter)) == 0) { int prop_is_valid; has_id = 1; @@ -936,6 +948,16 @@ int ast_ari_validate_bridge(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 Bridge field name failed validation\n"); + res = 0; + } + } else if (strcmp("technology", ast_json_object_iter_key(iter)) == 0) { int prop_is_valid; has_technology = 1; @@ -969,11 +991,21 @@ int ast_ari_validate_bridge(struct ast_json *json) res = 0; } + if (!has_creator) { + ast_log(LOG_ERROR, "ARI Bridge missing required field creator\n"); + res = 0; + } + if (!has_id) { ast_log(LOG_ERROR, "ARI Bridge missing required field id\n"); res = 0; } + if (!has_name) { + ast_log(LOG_ERROR, "ARI Bridge missing required field name\n"); + res = 0; + } + if (!has_technology) { ast_log(LOG_ERROR, "ARI Bridge missing required field technology\n"); res = 0; diff --git a/res/ari/ari_model_validators.h b/res/ari/ari_model_validators.h index 22ab43be8..326693950 100644 --- a/res/ari/ari_model_validators.h +++ b/res/ari/ari_model_validators.h @@ -1083,7 +1083,9 @@ ari_validator ast_ari_validate_application_fn(void); * - bridge_class: string (required) * - bridge_type: string (required) * - channels: List[string] (required) + * - creator: string (required) * - id: string (required) + * - name: string (required) * - technology: string (required) * LiveRecording * - cause: string diff --git a/res/ari/resource_bridges.c b/res/ari/resource_bridges.c index c07471816..ed3eba82e 100644 --- a/res/ari/resource_bridges.c +++ b/res/ari/resource_bridges.c @@ -695,7 +695,7 @@ void ast_ari_bridges_create(struct ast_variable *headers, struct ast_ari_bridges_create_args *args, struct ast_ari_response *response) { - RAII_VAR(struct ast_bridge *, bridge, stasis_app_bridge_create(args->type), ao2_cleanup); + RAII_VAR(struct ast_bridge *, bridge, stasis_app_bridge_create(args->type, args->name), ao2_cleanup); RAII_VAR(struct ast_bridge_snapshot *, snapshot, NULL, ao2_cleanup); if (!bridge) { diff --git a/res/ari/resource_bridges.h b/res/ari/resource_bridges.h index c5a832275..a7ccd3120 100644 --- a/res/ari/resource_bridges.h +++ b/res/ari/resource_bridges.h @@ -54,6 +54,8 @@ void ast_ari_bridges_list(struct ast_variable *headers, struct ast_ari_bridges_l struct ast_ari_bridges_create_args { /*! \brief Type of bridge to create. */ const char *type; + /*! \brief Name to give to the bridge being created. */ + const char *name; }; /*! * \brief Create a new bridge. |