[asterisk-commits] dlee: branch dlee/ASTERISK-22451-ari-subscribe r398976 - in /team/dlee/ASTERI...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 12 12:51:07 CDT 2013


Author: dlee
Date: Thu Sep 12 12:51:05 2013
New Revision: 398976

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=398976
Log:
Explicitly break out channels, bridges and endpoints in Application respons

Modified:
    team/dlee/ASTERISK-22451-ari-subscribe/res/ari/ari_model_validators.c
    team/dlee/ASTERISK-22451-ari-subscribe/res/ari/ari_model_validators.h
    team/dlee/ASTERISK-22451-ari-subscribe/res/stasis/app.c
    team/dlee/ASTERISK-22451-ari-subscribe/rest-api/api-docs/applications.json

Modified: team/dlee/ASTERISK-22451-ari-subscribe/res/ari/ari_model_validators.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22451-ari-subscribe/res/ari/ari_model_validators.c?view=diff&rev=398976&r1=398975&r2=398976
==============================================================================
--- team/dlee/ASTERISK-22451-ari-subscribe/res/ari/ari_model_validators.c (original)
+++ team/dlee/ASTERISK-22451-ari-subscribe/res/ari/ari_model_validators.c Thu Sep 12 12:51:05 2013
@@ -3382,18 +3382,42 @@
 {
 	int res = 1;
 	struct ast_json_iter *iter;
-	int has_event_sources = 0;
+	int has_bridge_ids = 0;
+	int has_channel_ids = 0;
+	int has_endpoint_names = 0;
 	int has_name = 0;
 
 	for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
-		if (strcmp("event_sources", ast_json_object_iter_key(iter)) == 0) {
-			int prop_is_valid;
-			has_event_sources = 1;
+		if (strcmp("bridge_ids", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_bridge_ids = 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 Application field event_sources failed validation\n");
+				ast_log(LOG_ERROR, "ARI Application field bridge_ids failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("channel_ids", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_channel_ids = 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 Application field channel_ids failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("endpoint_names", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_endpoint_names = 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 Application field endpoint_names failed validation\n");
 				res = 0;
 			}
 		} else
@@ -3415,8 +3439,18 @@
 		}
 	}
 
-	if (!has_event_sources) {
-		ast_log(LOG_ERROR, "ARI Application missing required field event_sources\n");
+	if (!has_bridge_ids) {
+		ast_log(LOG_ERROR, "ARI Application missing required field bridge_ids\n");
+		res = 0;
+	}
+
+	if (!has_channel_ids) {
+		ast_log(LOG_ERROR, "ARI Application missing required field channel_ids\n");
+		res = 0;
+	}
+
+	if (!has_endpoint_names) {
+		ast_log(LOG_ERROR, "ARI Application missing required field endpoint_names\n");
 		res = 0;
 	}
 

Modified: team/dlee/ASTERISK-22451-ari-subscribe/res/ari/ari_model_validators.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22451-ari-subscribe/res/ari/ari_model_validators.h?view=diff&rev=398976&r1=398975&r2=398976
==============================================================================
--- team/dlee/ASTERISK-22451-ari-subscribe/res/ari/ari_model_validators.h (original)
+++ team/dlee/ASTERISK-22451-ari-subscribe/res/ari/ari_model_validators.h Thu Sep 12 12:51:05 2013
@@ -1101,7 +1101,9 @@
  * - args: List[string] (required)
  * - channel: Channel (required)
  * Application
- * - event_sources: List[string] (required)
+ * - bridge_ids: List[string] (required)
+ * - channel_ids: List[string] (required)
+ * - endpoint_names: List[string] (required)
  * - name: string (required)
  */
 

Modified: team/dlee/ASTERISK-22451-ari-subscribe/res/stasis/app.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22451-ari-subscribe/res/stasis/app.c?view=diff&rev=398976&r1=398975&r2=398976
==============================================================================
--- team/dlee/ASTERISK-22451-ari-subscribe/res/stasis/app.c (original)
+++ team/dlee/ASTERISK-22451-ari-subscribe/res/stasis/app.c Thu Sep 12 12:51:05 2013
@@ -653,34 +653,42 @@
 struct ast_json *app_to_json(const struct app *app)
 {
 	RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
-	struct ast_json *array;
+	struct ast_json *channels;
+	struct ast_json *bridges;
+	struct ast_json *endpoints;
 	struct ao2_iterator i;
 	void *obj;
 
-	json = ast_json_pack("{s: s, s: []}",
+	json = ast_json_pack("{s: s, s: [], s: [], s: []}",
 		"name", app->name,
-		"event_sources");
-	array = ast_json_object_get(json, "event_sources");
+		"channel_ids", "bridge_ids", "endpoint_names");
+	channels = ast_json_object_get(json, "channel_ids");
+	bridges = ast_json_object_get(json, "bridge_ids");
+	endpoints = ast_json_object_get(json, "endpoint_names");
 
 	i = ao2_iterator_init(app->forwards, 0);
 	while ((obj = ao2_iterator_next(&i))) {
 		RAII_VAR(struct app_forwards *, forwards, obj, ao2_cleanup);
-		struct ast_json *uri = NULL;
-		int append_res;
+		RAII_VAR(struct ast_json *, id, NULL, ast_json_unref);
+		int append_res = -1;
+
+		id = ast_json_string_create(forwards->id);
 
 		switch (forwards->forward_type) {
 		case FORWARD_CHANNEL:
-			uri = ast_json_stringf("channel:%s", forwards->id);
+			append_res = ast_json_array_append(channels,
+				ast_json_ref(id));
 			break;
 		case FORWARD_BRIDGE:
-			uri = ast_json_stringf("bridge:%s", forwards->id);
+			append_res = ast_json_array_append(bridges,
+				ast_json_ref(id));
 			break;
 		case FORWARD_ENDPOINT:
-			uri = ast_json_stringf("endpoint:%s", forwards->id);
+			append_res = ast_json_array_append(endpoints,
+				ast_json_ref(id));
 			break;
 		}
 
-		append_res = ast_json_array_append(array, uri);
 		if (append_res != 0) {
 			ast_log(LOG_ERROR, "Error building response\n");
 			ao2_iterator_destroy(&i);

Modified: team/dlee/ASTERISK-22451-ari-subscribe/rest-api/api-docs/applications.json
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22451-ari-subscribe/rest-api/api-docs/applications.json?view=diff&rev=398976&r1=398975&r2=398976
==============================================================================
--- team/dlee/ASTERISK-22451-ari-subscribe/rest-api/api-docs/applications.json (original)
+++ team/dlee/ASTERISK-22451-ari-subscribe/rest-api/api-docs/applications.json Thu Sep 12 12:51:05 2013
@@ -146,9 +146,19 @@
 					"description": "Name of this application",
 					"required": true
 				},
-				"event_sources": {
+				"channel_ids": {
 					"type": "List[string]",
-					"description": "URI's for objects subscribed to.",
+					"description": "Id's for channels subscribed to.",
+					"required": true
+				},
+				"bridge_ids": {
+					"type": "List[string]",
+					"description": "Id's for bridges subscribed to.",
+					"required": true
+				},
+				"endpoint_names": {
+					"type": "List[string]",
+					"description": "{tech}/{resource} for endpoints subscribed to.",
 					"required": true
 				}
 			}




More information about the asterisk-commits mailing list