[asterisk-commits] dlee: branch dlee/ari-event-remodel2 r392434 - in /team/dlee/ari-event-remode...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 21 11:48:33 CDT 2013


Author: dlee
Date: Fri Jun 21 11:48:32 2013
New Revision: 392434

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392434
Log:
Update bridging model.

Modified:
    team/dlee/ari-event-remodel2/main/stasis_bridging.c
    team/dlee/ari-event-remodel2/res/res_stasis_http_bridges.c
    team/dlee/ari-event-remodel2/res/stasis_http/ari_model.c
    team/dlee/ari-event-remodel2/res/stasis_http/ari_model.h
    team/dlee/ari-event-remodel2/rest-api-templates/swagger_model.py
    team/dlee/ari-event-remodel2/rest-api/api-docs/bridges.json

Modified: team/dlee/ari-event-remodel2/main/stasis_bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/main/stasis_bridging.c?view=diff&rev=392434&r1=392433&r2=392434
==============================================================================
--- team/dlee/ari-event-remodel2/main/stasis_bridging.c (original)
+++ team/dlee/ari-event-remodel2/main/stasis_bridging.c Fri Jun 21 11:48:32 2013
@@ -340,10 +340,10 @@
 	}
 
 	json_bridge = ast_json_pack("{s: s, s: s, s: s, s: s, s: o}",
-		"bridgeUniqueid", snapshot->uniqueid,
-		"bridgeTechnology", snapshot->technology,
-		"bridgeType", capability2str(snapshot->capabilities),
-		"bridgeClass", snapshot->subclass,
+		"id", snapshot->uniqueid,
+		"technology", snapshot->technology,
+		"bridge_type", capability2str(snapshot->capabilities),
+		"bridge_class", snapshot->subclass,
 		"channels", json_channels);
 	if (!json_bridge) {
 		return NULL;

Modified: team/dlee/ari-event-remodel2/res/res_stasis_http_bridges.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/res/res_stasis_http_bridges.c?view=diff&rev=392434&r1=392433&r2=392434
==============================================================================
--- team/dlee/ari-event-remodel2/res/res_stasis_http_bridges.c (original)
+++ team/dlee/ari-event-remodel2/res/res_stasis_http_bridges.c Fri Jun 21 11:48:32 2013
@@ -171,6 +171,7 @@
 
 	switch (code) {
 	case 500: /* Internal server error */
+	case 404: /* Bridge not found */
 		is_valid = 1;
 		break;
 	default:
@@ -221,6 +222,7 @@
 
 	switch (code) {
 	case 500: /* Internal server error */
+	case 404: /* Bridge not found */
 		is_valid = 1;
 		break;
 	default:
@@ -277,6 +279,9 @@
 
 	switch (code) {
 	case 500: /* Internal server error */
+	case 404: /* Bridge not found */
+	case 409: /* Bridge not in Stasis application */
+	case 422: /* Channel not found, or not in Stasis application */
 		is_valid = 1;
 		break;
 	default:

Modified: team/dlee/ari-event-remodel2/res/stasis_http/ari_model.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/res/stasis_http/ari_model.c?view=diff&rev=392434&r1=392433&r2=392434
==============================================================================
--- team/dlee/ari-event-remodel2/res/stasis_http/ari_model.c (original)
+++ team/dlee/ari-event-remodel2/res/stasis_http/ari_model.c Fri Jun 21 11:48:32 2013
@@ -407,10 +407,23 @@
 {
 	int res = 1;
 	struct ast_json_iter *iter;
+	int has_bridge_class = 0;
 	int has_bridge_type = 0;
 	int has_channels = 0;
-
-	for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
+	int has_id = 0;
+	int has_technology = 0;
+
+	for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
+		if (strcmp("bridge_class", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_bridge_class = 1;
+			prop_is_valid = ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI Bridge field bridge_class failed validation\n");
+				res = 0;
+			}
+		} else
 		if (strcmp("bridge_type", ast_json_object_iter_key(iter)) == 0) {
 			int prop_is_valid;
 			has_bridge_type = 1;
@@ -432,6 +445,26 @@
 				res = 0;
 			}
 		} else
+		if (strcmp("id", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_id = 1;
+			prop_is_valid = ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI Bridge field id failed validation\n");
+				res = 0;
+			}
+		} else
+		if (strcmp("technology", ast_json_object_iter_key(iter)) == 0) {
+			int prop_is_valid;
+			has_technology = 1;
+			prop_is_valid = ari_validate_string(
+				ast_json_object_iter_value(iter));
+			if (!prop_is_valid) {
+				ast_log(LOG_ERROR, "ARI Bridge field technology failed validation\n");
+				res = 0;
+			}
+		} else
 		{
 			ast_log(LOG_ERROR,
 				"ARI Bridge has undocumented field %s\n",
@@ -439,6 +472,11 @@
 			res = 0;
 		}
 	}
+
+	if (!has_bridge_class) {
+		ast_log(LOG_ERROR, "ARI Bridge missing required field bridge_class\n");
+		res = 0;
+		}
 
 	if (!has_bridge_type) {
 		ast_log(LOG_ERROR, "ARI Bridge missing required field bridge_type\n");
@@ -447,6 +485,16 @@
 
 	if (!has_channels) {
 		ast_log(LOG_ERROR, "ARI Bridge missing required field channels\n");
+		res = 0;
+		}
+
+	if (!has_id) {
+		ast_log(LOG_ERROR, "ARI Bridge missing required field id\n");
+		res = 0;
+		}
+
+	if (!has_technology) {
+		ast_log(LOG_ERROR, "ARI Bridge missing required field technology\n");
 		res = 0;
 		}
 

Modified: team/dlee/ari-event-remodel2/res/stasis_http/ari_model.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/res/stasis_http/ari_model.h?view=diff&rev=392434&r1=392433&r2=392434
==============================================================================
--- team/dlee/ari-event-remodel2/res/stasis_http/ari_model.h (original)
+++ team/dlee/ari-event-remodel2/res/stasis_http/ari_model.h Fri Jun 21 11:48:32 2013
@@ -503,8 +503,11 @@
  * - exten: string (required)
  * - priority: long (required)
  * Bridge
+ * - bridge_class: string (required)
  * - bridge_type: string (required)
  * - channels: List[string] (required)
+ * - id: string (required)
+ * - technology: string (required)
  * LiveRecording
  * - id: string (required)
  * StoredRecording

Modified: team/dlee/ari-event-remodel2/rest-api-templates/swagger_model.py
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/rest-api-templates/swagger_model.py?view=diff&rev=392434&r1=392433&r2=392434
==============================================================================
--- team/dlee/ari-event-remodel2/rest-api-templates/swagger_model.py (original)
+++ team/dlee/ari-event-remodel2/rest-api-templates/swagger_model.py Fri Jun 21 11:48:32 2013
@@ -266,6 +266,10 @@
             parameter_json.get('allowableValues'), context)
         self.allow_multiple = parameter_json.get('allowMultiple') or False
         processor.process_parameter(self, context)
+        if parameter_json.get('allowedValues'):
+            raise SwaggerError(
+                "Field 'allowedValues' invalid; use 'allowableValues'",
+                context)
         return self
 
     def is_type(self, other_type):

Modified: team/dlee/ari-event-remodel2/rest-api/api-docs/bridges.json
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ari-event-remodel2/rest-api/api-docs/bridges.json?view=diff&rev=392434&r1=392433&r2=392434
==============================================================================
--- team/dlee/ari-event-remodel2/rest-api/api-docs/bridges.json (original)
+++ team/dlee/ari-event-remodel2/rest-api/api-docs/bridges.json Fri Jun 21 11:48:32 2013
@@ -31,8 +31,8 @@
 							"required": false,
 							"allowMultiple": false,
 							"dataType": "string",
-							"allowedValues": {
-								"type": "LIST",
+							"allowableValues": {
+								"valueType": "LIST",
 								"values": [
 									"mixing",
 									"holding"
@@ -61,6 +61,12 @@
 							"allowMultiple": false,
 							"dataType": "string"
 						}
+					],
+					"errorResponses": [
+						{
+							"code": 404,
+							"reason": "Bridge not found"
+						}
 					]
 				},
 				{
@@ -78,6 +84,12 @@
 							"allowMultiple": false,
 							"dataType": "string"
 						}
+					],
+					"errorResponses": [
+						{
+							"code": 404,
+							"reason": "Bridge not found"
+						}
 					]
 				}
 			]
@@ -107,6 +119,20 @@
 							"required": true,
 							"allowMultiple": true,
 							"dataType": "string"
+						}
+					],
+					"errorResponses": [
+						{
+							"code": 404,
+							"reason": "Bridge not found"
+						},
+						{
+							"code": 409,
+							"reason": "Bridge not in Stasis application"
+						},
+						{
+							"code": 422,
+							"reason": "Channel not found, or not in Stasis application"
 						}
 					]
 				}
@@ -233,18 +259,33 @@
 			"id": "Bridge",
 			"description": "The merging of media from one or more channels.\n\nEveryone on the bridge receives the same audio.",
 			"properties": {
+				"id": {
+					"type": "string",
+					"description": "Unique identifier for this bridge",
+					"required": true
+				},
+				"technology": {
+					"type": "string",
+					"description": "Name of the current bridging technology",
+					"required": true
+				},
 				"bridge_type": {
 					"type": "string",
 					"description": "Type of bridge technology",
 					"required": true,
-					"allowedValues": {
-						"type": "LIST",
+					"allowableValues": {
+						"valueType": "LIST",
 						"values": [
 							"mixing",
 							"holding"
 						]
 					}
 				},
+				"bridge_class": {
+					"type": "string",
+					"description": "Bridging class",
+					"required": true
+				},
 				"channels": {
 					"type": "List[string]",
 					"description": "Id's of channels participating in this bridge",




More information about the asterisk-commits mailing list