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
This commit is contained in:
Jonathan Rose
2013-12-17 23:25:49 +00:00
parent 91d0f30506
commit b0bb03e916
20 changed files with 145 additions and 24 deletions

View File

@@ -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;

View File

@@ -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

View File

@@ -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) {

View File

@@ -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.